I'm really bad at trig
I'm trying to work out object placement and I'm having trouble because my trig is so bad.
I need to find an end point in in 2D space considering I have the following information:
A starting point, say x = y = 10.0f;
An Angle between the start point and the end point, 0.0 to 359.999f
The distance from the starting point to the end point, say 10.0f;
How do I find the x and y coords of the end point?
Thanks, and sorry about my lack of rudimentary maths skills.
Let's call the start point vector 'start', the angle 'alpha' and the distance 'd'. Then do the following:
1) Rotate start over alpha.
2) Normalize the result to have magnitude 1.0.
3) Multiply the result by d.
4) The resulting vector is the end vector.
(there's little trigonometry involved however)
Greetz,
Illco
1) Rotate start over alpha.
2) Normalize the result to have magnitude 1.0.
3) Multiply the result by d.
4) The resulting vector is the end vector.
(there's little trigonometry involved however)
Greetz,
Illco
1) Use Google and find:
For the others points:
2) Normalize a vector:
3) Multiply a vector by a scalar:
I'd better not be doing your homework! If you look for stuff like this for yourself, it will stick at some point and improve your math skills.
x' = cos(alpha) * x - sin(alpha) * yy' = sin(alpha) * x + cos(alpha) * y
For the others points:
2) Normalize a vector:
magnitude = sqrt(x*x + y*y)x = x / magnitudey = y / magnitude
3) Multiply a vector by a scalar:
x = x * dy = y * d
I'd better not be doing your homework! If you look for stuff like this for yourself, it will stick at some point and improve your math skills.
How about :
1) knowing the length is 10.0f, create a vector (0.0f, 10.0f) and rotate it by the angle alpha
2) add the rotated vector to the original vector.
3) done
Saves doing normalisation etc. Picture it like starting with a vector up the Y axis of the length you want ie: 10.0f, and rotating it by alpha. That gives you the actual vector you need, it just needs translating by the original vector into position, which is like "starting it off" from the original vector position.
Remember the starting point is really just like a vector from the origin. So you can move the "tail" of the new vector to the "head" of the old one to give the end point.
I recommend drawing it down on graph paper, it simplifies it when you cansee it happening visually.
Hope that gives some furthur ideas :)
1) knowing the length is 10.0f, create a vector (0.0f, 10.0f) and rotate it by the angle alpha
2) add the rotated vector to the original vector.
3) done
Saves doing normalisation etc. Picture it like starting with a vector up the Y axis of the length you want ie: 10.0f, and rotating it by alpha. That gives you the actual vector you need, it just needs translating by the original vector into position, which is like "starting it off" from the original vector position.
Remember the starting point is really just like a vector from the origin. So you can move the "tail" of the new vector to the "head" of the old one to give the end point.
I recommend drawing it down on graph paper, it simplifies it when you cansee it happening visually.
Hope that gives some furthur ideas :)
GCoder
x = x_start + cos( alpha ) * distance;
y = y_start + sin( alpha ) * distance;
You *really* should learn some math, becouse this is as basic as it gets.
y = y_start + sin( alpha ) * distance;
You *really* should learn some math, becouse this is as basic as it gets.
You should never let your fears become the boundaries of your dreams.
April 18, 2005 09:51 AM
In order then.
@Illco
What does part 1 do exactly and why? I'm ok with normalization and scalar multiplication it's the raw trig that really hurts me. Thanks.
@GCoder
Lol. I'll definitely bare that in mind if I can't get the trig to stick this time.
@darkwing
Isn't that limited to triangles where the angles is less than 90degrees? I could be wrong and probably am.
On the not knowing fundimental mathematics and not googling front.
Sorry about the inconvenience but my old maths books and google both lack that wonderful phenomenon know as human feed back. I'll almost certainly learn better by discussing the issue with others.
Thanks for your patience.
@Illco
What does part 1 do exactly and why? I'm ok with normalization and scalar multiplication it's the raw trig that really hurts me. Thanks.
@GCoder
Lol. I'll definitely bare that in mind if I can't get the trig to stick this time.
@darkwing
Isn't that limited to triangles where the angles is less than 90degrees? I could be wrong and probably am.
On the not knowing fundimental mathematics and not googling front.
Sorry about the inconvenience but my old maths books and google both lack that wonderful phenomenon know as human feed back. I'll almost certainly learn better by discussing the issue with others.
Thanks for your patience.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement