Jump to content
  • Advertisement
Sign in to follow this  
Dookie

Quick math question...

This topic is 5016 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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! :)

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites

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!!

Share this post


Link to post
Share on other sites
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].

Share this post


Link to post
Share on other sites
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! :)

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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")

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!