Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Reversing a vector...

Author
Message
iaretony
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 18th Jul 2003 02:47
How do you get a vector2 to point in the opposite direction (IE, + || - 180 degrees)?

Tony
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 18th Jul 2003 03:06
well you could always do



that way positive or negative it'll just swap the -/+
but i thought that was pretty obvious math

iaretony
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 18th Jul 2003 03:56
I was hoping for something slicker... Like:

scale vector2 fw_trace_vector, fw_trace_vector, -1

Will that work? At first I thought so, but now I think it will only
work if the x and y components are positive...

Tony

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 18th Jul 2003 05:39
i dunno why you'd think that somehow doing it with the scaler would help... i mean all of the 3dmath commands can be recreated (and work just as fast) if made by hand.
atleast this way its 100% accurate

keeblerElf
23
Years of Service
User Offline
Joined: 11th Jun 2003
Location: United States
Posted: 18th Jul 2003 07:52
Yeah all you need to do to rotate a vector 180 degrees is to multiple the vector by the scalar -1. if you want to rotate a vector by a different degree than say you have a know vector A and and unknown vector B and you want to rotate it C degrees that you could solve (AoB)/|A+B|=C where AoB is the dot product of vectors A and B

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 18th Jul 2003 07:56
but what is the point?
you end up spending like 20steps to do the exact same as the code i've provided much slower... i think less should be though about on how "neat" or "looks" of the code is and more on the actual features.

Login to post a reply

Server time is: 2026-07-21 12:50:15
Your offset time is: 2026-07-21 12:50:15