Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#101 Coder's Corner » installing C++ libraries » 2008-06-28 09:12:18

mikau
Replies: 4

When I install a new library, I am typically given a folder, with the name of the library, containing a bunch of subfolders, with names like: builds, src,  docs, include and others.

Now I understand these files need to be compiled and some files created or moved into the appropriate directories, but precisely how you do this, I don't know. Usually I Google walk-throughs  on the web for how to install a particular library, but it seems to be a different process every time. Furthermore, often they suggest  you install something else just to enable the installation.

Isn't there any standard method of distributing and installing a library in C++? Why do I have to learn a new dance every time?

#102 Re: Coder's Corner » OpenGL question (Luca?) » 2008-06-24 21:27:40

hmmm... you're right! Mind you, thats exactly how the matrix equation was displayed in the book. shame

but regardless, that doesn't seem right. OpenGL performs the transformations in the reverse order of when you specify them.

Say you start with the model View matrix as the Identity. Then you specify a rotation matrix R, a translation matrix T, ands a scaler matrix S, in that order. Each transformation right multiplies the new matrix by the old one, so we get: (R*T*S) as our modelview matrix.

If we had to left multiply a 4vector V (or rather, a 1x4 matrix) by this matrix, V(R*T*S), that would result in the transformations occurring in the order in which they were specified, and not in reverse, which is not how its supposed to work. Unless perhaps, the reverse order process is not used for the Projection Matrix.

#103 Re: Coder's Corner » Code snippets » 2008-06-24 14:16:36

Here is a function i've used in pretty much every game program I've written.  PolarAngle, it calculates the directed angle from (from_x, from_y) to (to_x, to_y) in degrees.

//remember to include math.h
float polarAngle(float from_x, float from_y, float to_x, float to_y)
{

  float h, v, r;
 
  v = to_y - from_y;   
  h = to_x - from_x;    

  if ((h == 0) && (v < 0)) { return 270;}     // avoid division by zero
  if ((h == 0) && (v > 0)) { return 90; }     // avoid division by zero
  if ((h == 0) && (v == 0)) { return 0; }     // points overlap, no angle

  r = atan(v/h) * 180/M_PI;                // convert radians to degree's

  if (h < 0)
  r+= 180;

  return r;

}

note the function sometimes produces negative angles, so you might like to add
if (r < 0) r+= 360;  before the return statement.

#104 Re: Coder's Corner » OpenGL question (Luca?) » 2008-06-24 13:32:40

am I going mad, or does my openGL book not understand matrix multiplication?

#105 Re: This is Cool » Wierd graph » 2008-06-12 09:31:57

Picky picky, Jane! tongue

Anyway, it is fun to replace x in many functions with b*sin(a*x), as it must result in a repeating pattern.

Try graphing sin(pi*sin(x)) for instance!

#106 Re: This is Cool » Wierd graph » 2008-06-11 07:50:41

by wrapping the cosine in absolute value, you can make the graph continuous! smile

ln(abs((cos(x))/(e^(-x))))

#107 Re: Coder's Corner » Free Helpful Calculator » 2008-06-10 06:25:48

bwahaha! good question, Mathsisfun!

-= Thanks? he subtracted thanks rather than giving it! This guy can't be trusted!

#108 Re: Help Me ! » Find the Radius of convergence for the following power series.... » 2008-06-01 09:50:14

well I recognized the first as being the maclauren expansion of e^x where x = 1.

I seem to remember there being an easy convergency test to show that 1/n! converges though. Just can't remember which.

#109 Re: Help Me ! » Arc Length of a Parabola » 2008-06-01 07:42:28

oooh, its quite simple. You can compute it easily in terms of e. (in fact, i think thats how they are defined)



the INVERSE of these functions, I'm not sure I remember. I'm pretty sure its an expression involving ln(x).

#110 Re: Help Me ! » Find the Radius of convergence for the following power series.... » 2008-06-01 07:31:05

and how did you derive the second relation? thats kinda cool!

(edit) wait I get it! Every factorial after 2 has to be even! What a nifty trick! smile

#111 Re: Help Me ! » Find the Radius of convergence for the following power series.... » 2008-05-31 14:57:23

using the ratio test, divide the (n+1)th term by the n'th term, to get:

which reduces to:

now in the limit, as n approaches infinity (which is what we calculate when we apply the ratio test) the factor of (n)/(n+1) approaches 1, so all that we need be concerned with is x^(n! n), which is basically x^(infinity)

so the rule is, for what values of x will this limit have an absolute value less than 1? Intuitively, we can see that the answer is, -1 < x < 1. At these values, the high power will cause x to reduce itself, smaller and smaller and smaller until it eventually reaches zero.

What the ratio test doesn't tell you is what happens when the absolute value of the ratio is exactly 1, or in this case, where x = 1 or -1. (note the fact that both the ratio, and x must have an absolute value of 1 is purely coincidental)

so now we need to consider two specific case values: the series where x = 1, and the series where x = -1, that is:


and

my helpfulness stops here though, as I cannot remember how you work with these. But I'm pretty sure you can solve them using other methods. What you have to do is see if 1 and -1 are included in the radius of convergence, which will tell you if -1 and 1 can be included at the endpoints of the radius of convergence.

But actually, all this problem asks is the radius of convergence, which i believe does not require you to find out what happens at the very edge of the radius, only the overall size of the radius. So really, you don't need to worry about those two series.

#112 Re: Help Me ! » Arc Length of a Parabola » 2008-05-31 14:09:16

well... I assume that integrator just gives you the antiderivative, so you could just plug (a) into that expression, and subtract that from the result of plugging (b) into that expression.
In otherwords,

then the evaluation is (F(b) - F(a))

But somehow i think you'd know that!

I think they are using inverse hyperbolic trigonometric substitution to do that:

let sinh(u) = 2x

then:

4x^2 = sinh^2(u) and dx = (1/2) cosh(u) du

so we have:

Note I've replaced a and b with a* and b* to represent the values of u where x = a and x = b respectively. Now using the identity, sinh^2 + 1 = cosh^2, we get

now I don't really remember how you handle even powers of hyper-trig functions, but I'm pretty sure there's an identity somewhere that will simplify this.

Anyway, when you're done finding the antiderivative in terms of u, you resubstitute for u using the relation sinh(u) = 2x, or equivalently, sinh^-1(2x) = u, and then simplify. Once you replace the expression with one involving only x, then your limits of evaluation move back to a, and b (rather than a* and b*). I'm assuming what you were given by the calculator is what you get as a result.

#113 Re: Help Me ! » 3d geometry proof: unsolvable? » 2008-05-31 13:49:06

could you state your congruency postulates/theorems there, infinit?


"so ABC is directly similar to ABD" by what reasoning? What simularity theorem are you using?

#114 Re: Help Me ! » onto and one to one » 2008-05-28 23:35:30

JaneFairfax wrote:

Mikau, you didn’t answered the actual question: Can T be onto (i.e. surjective)? In any case, your analysis is wrong: T is a mapping from

to
, not the other way round.

wow! I didn't even see this until just now.

argh! Row major format, of course! *face slap* silly me!

but I've never heard the term 'onto' to mean surjective. Thats weird!

#115 Re: Coder's Corner » OpenGL question (Luca?) » 2008-05-27 09:44:19

I think 'translation' or 'transformation' matrix is the term for it?

#116 Re: Coder's Corner » OpenGL question (Luca?) » 2008-05-27 09:42:38

But surely you would know the translation required already and do it first before doing any rotations?

pooossibly! But one thing I like making is a robot model that can be positioned based on a set of angle parameters. When updating its position, I would basically assemble each piece in a series of rotations and translations. For instance, you would rotate the forearm by say, leftElbowAngle, and then move it onto the bottom of the upper arm, and then the two of them would be rotated by leftArmShoulderAngle. The entire upper body could be rotated about its waste, and finally the entire model could be rotated and shifted to its appropriate location.

Now according to that, if different parts of the body are rotated at all these different angles, then calling glTranslate to shift its location would send them off in all different directions.

now i MAY be able to reorder it so that every piece is rotated before its translated, I just suspect that in certain scenarios, you might need to shift after rotating, and it would be a nightmare.

#117 Coder's Corner » OpenGL question (Luca?) » 2008-05-27 07:37:40

mikau
Replies: 8

I once wrote a program to do wire frame projections for me, and I guess I'm kind of used to my own way of doing things. But I got a book on OpenGL that I've been reading over summer break, and the way they do certain things perplexes me.

One thing I read today is that when doing model rotations, you effectively rotate a models coordinate system. This means that when you use GL translate to shift the model over, say by a vector of (1, 0, 0), it gets shifted by that vector, relative to its new coordinate system.

That sounds like a hassle to me. Say you had a 3d object thats been rotated several ways, and you want to transfer the object onto say.... a table, by shifting its location. You'd have to calculate the coordinates of the table with respect to the objects weirdly rotated coordinate system, and that sounds unnecessarily complicated for such a simple thing.

Is there a simpler way to move an object in this fashion?

#118 Re: Dark Discussions at Cafe Infinity » Global Warming- It's Happening! » 2008-05-22 03:53:24

Hey guys! I was going to make a new thread about this but I remembered we had a global warming thread. So here's what I had to say.

Despite what appears to be growing concern for global warming, and carbon dioxide levels in the media and politics, all I ever see in my urban Philadelphia neighborhood is more and more trees being cut down because they are an annoyance. Back when I first moved to this neighborhood, about 15 years back, large oak and maple trees lined the avenues, and where plentiful in neighborhood streets, and backyards. By now, trees have all but completely disappeared. I once asked a neighbor why he was cuttting his tree down in his yard. He said "Because they're a mess. Thats all trees are, is a mess!"

aren't trees a little more than that? Aren't they a crucial component of our environment necessary for our own existence?

I understand that trees do make messes, and they can cause damage to plumbing systems, sewer pipes, and whatnot. But seriously, how much could global warming be reduced if we  spent time planting trees in places where they are scarce (such as urban neighborhoods and cities) instead of cutting them down?

#119 Coder's Corner » general programming knowledge » 2008-05-13 20:28:44

mikau
Replies: 2

I will soon be getting my associates in computer science.
I have taken two courses in Java (mostly just learning to use the language), a course in data structures, assembly language, and computer architecture and organization. Thats it for my schools  compy sci curriculum in terms of computer science courses (of course there are plenty of math courses and other things)

Apart from that, I have taught myself C++ and do practice programming for fun.

So I feel like I should know something about programming, yet I read programming articles and message boards and I still have no idea whats going on. Why?

I think the problem is that I spend all the time learning about how to program in specific languages, setting up data structures, implementing algorithms, etc. But I learn nothing about say..what a Project is? Whats a DLL? Whats an API? What is a module? How do you set up projects, where do you place the files, how do the files interact? 

I usually just Google these things, but often the definitions contain more unfamiliar terminology, and I get just a hazy idea of whats going on.

I'm really having trouble explaining this, because I don't fully understand what it is I'm lacking. But I feel like I need to know more about... how do we actually put our code together, and turn them into actual programs. How do we access predefined resources and make them work with our programs, and just...general programming knowledge?

I guess I feel like the only thing I understand is source code. But there is clearly, far more to a programming project than source code.

I have the whole summer off and I am hellbent on gaining as much programming knowledge as I can, but I'm not really sure where to look. I have looked at some books, but many of them again seem to use a lot of terminology and information that I've just not been introduced to, and I'm confounded by it.

Does anyone actually bother to explain these things, or are programmers just assumed to know it after a course or two in C++? swear

So I guess my question is, if I want to learn about general programming knowledge, or the basics of the programming environment, where should I begin?

#120 Re: This is Cool » Inequality matrix algebra? » 2008-05-01 12:42:53

well one way its easy to prove. But showing the implication works the other way puts a restriction on the solution sets. I had a proof that showed how this could be used for reduction, but i can't remember exactly what it was, or how i proved it. argh!

I'll keep thinking about it.

#121 Re: This is Cool » Inequality matrix algebra? » 2008-05-01 09:35:35

sweet!

Anyway, I'm working on the next part of the discussion, it involves another proof, and i can't remember exactly how I did it.

#122 Re: This is Cool » Inequality matrix algebra? » 2008-05-01 08:23:30

part 2.



In otherwords, where the coefficient of one of the variables is equal and opposite in sign, they may be added together, and the resulting inequality has a solution if and only if the first two have solutions.

To show this, suppose the first two inequalities have a solution (x, y, z), then:



rearranging:


we therefore, must have that for these solution values,


rearranging

which implies the sum of the inequalities also has a solution.

Now suppose there is no point (x, y, z) such that


are both satisfied, and there is a point (x, y, z) such that


has a solution.

rearranging the latter inequality, for the solution point

now suppose we take a value that lies between these two by letting u equal the average of the values on either side. we therefore have:

or


and

rearranging we get


and

now suppose we chose the value x such that u = ax, (x = a/u)

we therefore have

and

a contradiction. Thus we are finished with the proof.

#123 Re: This is Cool » Inequality matrix algebra? » 2008-05-01 07:39:22

Okay, first for this discussion I'm going to be dealing with 'less than or equal to, greater than or equal to' I think you can also apply the same reasoning for > and < but for now, i'm dealing only with ≤ and ≥

I'm going to post these in parts, as I work them out.

part 1. matrix representation

the first thing is how to represent a system of inequalities as a matrix. Simple, put all variables on the left side, the constants on the right side, and multiply each equation by -1 in order to set all inequality signs in the same direction, for the sake of consistency, always set it to '≤'


so the matrix

would represent:

x + 4y - 3z ≤ 2
5x + 2y + yz ≤ 5
-8x + 4y - 2z ≤ -6

simple, right?

Now here are some algebra rules for the matrix. We may, of course,
swap two rows.
We may
multiply a row by a positive scaler,
and we can
add two rows together. (not subtract)

#124 Re: This is Cool » Inequality matrix algebra? » 2008-05-01 07:26:42

like I said, my solution deals primarily with, does a solution exist? I don't exactly remember to what extent it shows you the actual solutions, I think it does. But I don't remember how far it goes.

My method is complicated, and I'll have to remember as I go along. I'll start working on the post now.

#125 Re: This is Cool » Inequality matrix algebra? » 2008-05-01 07:17:59

well for now, lets just worry about the following question

how can we show that a solution exists?

my method essentially deals with that. I THINK you can use it to work backwards and find the exact restrictions, but i have to recall how i did this. Its been several months since i played with this.

nope, but I guess it would be under the same principle as solving equalities?

not really. At least not my method. In normal matrix algebra, for a system of equations, if we have two rows, like
1 2 3
1 4 1

we subtract one row from the other to reduce it to


1 2 3
0 2 -2

and again to get

1 0 5
0 2 -2

problem though. If we are dealing with inequalities, such as
x + y < 5 and
x - 2y < 2

you cannot subtract one from the other, you can only add. So we cannot apply the same method to reduce it row by row.

Board footer

Powered by FluxBB