AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   NegateVector() broken? (https://forums.alliedmods.net/showthread.php?t=135120)

MomemtumMori 08-12-2010 21:23

NegateVector() broken?
 
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?

javalia 08-13-2010 00:11

Re: NegateVector() broken?
 
negativing a vector means reverse vector`s "direction".
so vector`s "length" will not be changed. only direction will be changed.

javalia 08-13-2010 00:15

Re: NegateVector() broken?
 
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

MomemtumMori 08-13-2010 18:22

Re: NegateVector() broken?
 
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

javalia 08-13-2010 23:14

Re: NegateVector() broken?
 
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.

MomemtumMori 08-14-2010 10:35

Re: NegateVector() broken?
 
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

javalia 08-14-2010 10:45

Re: NegateVector() broken?
 
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 08-14-2010 10:50

Re: NegateVector() broken?
 
more edit : u are want to change angle of client, if so just do this

- pseudocode

negatevector(vector1)

teleportclient(null, vectortoangle(vector1) null)

javalia 08-14-2010 10:51

Re: NegateVector() broken?
 
hm...my pseudo code is suck. i should not use it more lol

Damizean 08-14-2010 10:53

Re: NegateVector() broken?
 
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]; 



All times are GMT -4. The time now is 05:30.

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