Raised This Month: $32 Target: $400
 8% 

NegateVector() broken?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MomemtumMori
SourceMod Donor
Join Date: Oct 2009
Old 08-12-2010 , 21:23   NegateVector() broken?
Reply With Quote #1

I need to reverse a vector.
So i tought using stock NegateVector(Float:vec[3])

but it doesnt change the value at all!

i even tryed doing it manually.

camAngle2[0] = -clientCamAngle[0];
camAngle2[1] = -clientCamAngle[1];
camAngle2[2] = -clientCamAngle[2];

and i got the same result.


Help please?
MomemtumMori is offline
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 08-13-2010 , 00:11   Re: NegateVector() broken?
Reply With Quote #2

negativing a vector means reverse vector`s "direction".
so vector`s "length" will not be changed. only direction will be changed.
javalia is offline
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 08-13-2010 , 00:15   Re: NegateVector() broken?
Reply With Quote #3

if u are really want to see change, just convert that reversed and original vectors to angle and print it. than u will able to see vectors in angle is different
javalia is offline
MomemtumMori
SourceMod Donor
Join Date: Oct 2009
Old 08-13-2010 , 18:22   Re: NegateVector() broken?
Reply With Quote #4

ok. but thats already an angle vector from

MakeVectorFromPoints(point1, point2, vecResult);
GetVectorAngles(vecResult, clientCamAngle);

and that makes the player look in the exact opposite direction. I dont see the point into converting an angle vec to another angle vector.. but ill try anyway.


EDIT
Heres the result

point1 : 5553.742187 5676.272460 -799.968750
point2 : 5339.999511 6338.448730 -807.968750
vecResult: -213.742675 662.176269 -8.000000
clientCamAngle : 0.658714 107.889465 0.000000
negate() clientCamAngle : 0.658714 107.889465 0.000000
angles() clientCamAngle : 0.000000 89.918075 0.000000

last line is always the same or sometime changes to : 0.000000 90.0000000.000000
no matter what direction im aiming

Last edited by MomemtumMori; 08-13-2010 at 18:46. Reason: Testing
MomemtumMori is offline
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 08-13-2010 , 23:14   Re: NegateVector() broken?
Reply With Quote #5

MakeVectorFromPoints(point1, point2, vecResult);
GetVectorAngles(vecResult, clientCamAngle);

vecresult is direction vector. yes, it is vector.
but, clientcamangle is not vector.
it is angle value. like 0˚ ~ 360˚

from it is not vector, u will get incorrect result from reversing that vector.

and if u want to get reversed direction of client view angle,
just get client eye angle and change it onto vector(u must use vector from first vector buffer of that fucntion) and negate that vector and transfrom it to angle.
javalia is offline
MomemtumMori
SourceMod Donor
Join Date: Oct 2009
Old 08-14-2010 , 10:35   Re: NegateVector() broken?
Reply With Quote #6

im confused <_>

I tryed to do that based on your explanation
PHP Code:
    new Float:vecResult[3];
    
MakeVectorFromPoints(point1point2vecResult);
    
    new 
Float:clientAngles[3];
    
GetVectorAngles(vecResultclientAngles);
    
    new 
Float:clientAngleVector[3];
    
GetAngleVectors(clientAnglesclientAngleVectorNULL_VECTORNULL_VECTOR);
    
NegateVector(clientAngleVector);
    
    
GetVectorAngles(clientAngleVectorclientAngles);
    
    
TeleportEntity(clientNULL_VECTORclientAnglesNULL_VECTOR); 
but its still not pointing in the right direction
MomemtumMori is offline
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 08-14-2010 , 10:45   Re: NegateVector() broken?
Reply With Quote #7

no not that.
if u want to just get reversed vector of client eye view,

- pseudocode

decl clienteyeangle

getclienteyeangle(client, clienteyeangle)

decl vector1

getvectorfromangle(clienteyeangle, vector1, null, null)


negatevector(vector1)

teleportclient(vector1)
javalia is offline
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 08-14-2010 , 10:50   Re: NegateVector() broken?
Reply With Quote #8

more edit : u are want to change angle of client, if so just do this

- pseudocode

negatevector(vector1)

teleportclient(null, vectortoangle(vector1) null)
javalia is offline
javalia
Senior Member
Join Date: May 2009
Location: korea, republic of
Old 08-14-2010 , 10:51   Re: NegateVector() broken?
Reply With Quote #9

hm...my pseudo code is suck. i should not use it more lol
javalia is offline
Damizean
SourceMod Donor
Join Date: Mar 2009
Old 08-14-2010 , 10:53   Re: NegateVector() broken?
Reply With Quote #10

Your issue is that the - unary operator doesn't work with floats, I came across that issue recently, so your code would need to be:
PHP Code:
VecNegated[0] = 0.0 Vec[0];
VecNegated[1] = 0.0 Vec[1];
VecNegated[2] = 0.0 Vec[2]; 
__________________
Dat annoying guy
Damizean is offline
Send a message via AIM to Damizean Send a message via MSN to Damizean
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode