What do these functions do?

Discussions about Coding and Scripting
Post Reply
User avatar
Saya-chan
Adept
Posts: 446
Joined: Mon Jun 02, 2008 10:46 am
Personal rank: Former UT99 modder
Location: Vigo, Galicia
Contact:

What do these functions do?

Post by Saya-chan »

Been coding for years, but there are some functions and operators I still don't know what they exactly do. Could anyone enlighten me?

<<, >> and >>> (int A, int B)
<<, >> (vector A, rotator B)
Cross (vector A, vector B)
Invert (out vector X, out vector Y, out vector Z)
MirrorVectorByNormal (vector Vect, vector Normal)
GetUnAxes (rotator A, out vector X, out vector Y, out vector Z)
OrthoRotation (vector X, vector Y, vector Z)
Image
  ~♥~ Bless the Cute Emperor ~♥~
User avatar
Feralidragon
Godlike
Posts: 5493
Joined: Wed Feb 27, 2008 6:24 pm
Personal rank: Work In Progress
Location: Liandri

Re: What do these functions do?

Post by Feralidragon »

Code: Select all

<<, >> and >>> (int A, int B)
Shift Left: << : Shifts the bits of the first operand to the left
Shift Right (Arithmetic): >> : Shifts the bits of the first operand right, maintaining its signum
Shift Right: >>> : Shifts the bits of the first operand right, filling with zeroes
Source: UnrealWiki

Code: Select all

<<, >> (vector A, rotator B)
What >> does is this in UScript:

Code: Select all

GetAxes( B, X, Y, Z);
return A.X*X + A.Y*Y + A.Z*Z;
while << does this:

Code: Select all

GetUnAxes( B, X, Y, Z);
return A.X*X + A.Y*Y + A.Z*Z;

Code: Select all

Cross (vector A, vector B)
Basically, this one returns a perpendicular vector that results from the intersection from 2 vectors. For a better explanation, here: http://en.wikipedia.org/wiki/Cross_product
I must say this function saved me a lot of trouble in the vehicles.

Code: Select all

Invert (out vector X, out vector Y, out vector Z)
I am not sure what this one does... Never used it as well.

Code: Select all

MirrorVectorByNormal (vector Vect, vector Normal)
Mirrors a vector about a specified normal vector.
Think of a projectile p with a certain speed vector that hits a wall with a certain normal vector HitNormal and gets reflected without any damping. The projectile's new speed is what you get from MirrorVectorByNormal(p.Velocity, HitNormal). This can also be calculated through:

Code: Select all

Vect - (Vect dot Normal(HitNormal)) * Normal(HitNormal)
(this is used e.g. by the Ripper blades)
Source: UnrealWiki

Code: Select all

GetUnAxes (rotator A, out vector X, out vector Y, out vector Z)
Assigns the axis vectors of Rot(0,0,0) to X, Y and Z, in terms of A's Local Rotation. The same result as GetAxes(A,X,Y,Z) followed by Invert(X,Y,Z). If you think of X, Y and Z as 3x3 matrix, GetUnAxes returns the transposed matrix relative to what GetAxes would return with the same rotator.
Source: UnrealWiki

Code: Select all

OrthoRotation (vector X, vector Y, vector Z)
Returns a rotator from three orthogonal vectors.
Source: UnrealWiki
User avatar
Saya-chan
Adept
Posts: 446
Joined: Mon Jun 02, 2008 10:46 am
Personal rank: Former UT99 modder
Location: Vigo, Galicia
Contact:

Re: What do these functions do?

Post by Saya-chan »

Thanks a lot. Now I think I know how to fix some problems and add some new features to mods ;)
Image
  ~♥~ Bless the Cute Emperor ~♥~
Post Reply