Quick math question...

Started by
6 comments, last by GameDev.net 19 years, 6 months ago
Here's an easy one, and I'm drawing a blank and can't seem to figure it out... First off, I have a 2d normalized vector. Just for simplicity's sake, let's say it's (0.25, 0.75). What I want to do is turn that (0.75) into (1.00) and turn (0.25) into whatever would allow the first number to be (1.00) but still point in the same direction... Hard to explain, but basically I want to scale the vector to allow the larger (or smaller, if the 'larger' number is negative) number to be 'one' (or 'negative one'). So, if the vector was (0.33, 0.66), I'd want it to end up being (x.x, 1.0). If the original vector was (-0.2, -0.8), I'd want it to end up being (-x.x, -1.0). If the original vector was (-0.6, 0.4), I'd want it to end up being (-1.0, y.y)... I apologize if this doesn't make any sense at all, because I really stink at explaining stuff! But if you sorta muck through what I'm trying to explain, maybe an equasion you know will come to mind. Thanks in advance for the help, I really appreciate it! :)
"The crows seemed to be calling his name, thought Caw"
Advertisement
if your vector is [x,y] , if you scale it by 1/y , you'll get
[x,y]*(1/y) = [x*(1/y) , y*(1/y)] = [x/y,1.0]
Its really easy. You're just scaling both components by the same amount. Given a 2D vector (x, y), if you want y to be 1.0, the scaled vector is:

scaled vector = (x/fabsf(y), y/fabsf(y))              = (x/fabsf(y), 1.0 or -1.0);


If you want the *larger* of x or y to become 1/-1, then do this:

multiplier = 1.0/(max(fabsf(x), fabsf(y)));scaled vector = (x * multiplier, y * multiplier);
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

these are not normalize vectors as long as I know!!!

and if you want your vector to be (x.x, 1.0), it doesn't have the choice to be (0.0, 1.0)

maybe you should revise your math!!
cyberg- cyberg_coder@hotmail.com- http://members.xoom.com/cybergsoft
Quote:Original post by cyberg
these are not normalize vectors as long as I know!!!

Depends on which norm you're talking about. When talking about the L1-norm, they are normalized. The L1-norm is the sum of the absolute values of all components.
Quote:
and if you want your vector to be (x.x, 1.0), it doesn't have the choice to be (0.0, 1.0)

Again, that depends on the type of norm used. The Linfinity-norm is the maximum value of all components in the vector, so normalizing the vector with respect to the Linfinity-norm is done as the two previous posters said.

Quote:
maybe you should revise your math!!

Here's some reading for you about vector norms [rolleyes].
Dang y'all are quick! Thanks for all the info, I'll play around with those ideas and see if I can get it all to work.

As far as increasing my knowledge of vector math and such, what field of math (algebra, geometry, trig, etc) should I study?

Thanks again! :)
"The crows seemed to be calling his name, thought Caw"
Quote:Original post by Dookie
Dang y'all are quick! Thanks for all the info, I'll play around with those ideas and see if I can get it all to work.

As far as increasing my knowledge of vector math and such, what field of math (algebra, geometry, trig, etc) should I study?

Thanks again! :)

i think, all fields. But you have to do algebra and some geometry first and only then do trig...
Quote:Original post by cyberg

and if you want your vector to be (x.x, 1.0), it doesn't have the choice to be (0.0, 1.0)



That's a true statement only if the result vector also needs to be normalized. (under the standard definition of "normalized")

This topic is closed to new replies.

Advertisement