LuaDocs/Vector

From Data Realms Wiki

Jump to: navigation, search

Contents

Has no parent class

Generic Class. A useful 2D float vector.

Go back to Class Index


Properties

ClassName

Read-only property. The class name of this Vector.A string with the friendly-formatted type name of this Vector.

RoundedX

Read-only property. Returns the rounded integer X value of this Vector.A int value that represents the X value of this Vector.

RoundedY

Read-only property. Returns the rounded integer Y value of this Vector.A int value that represents the Y value of this Vector.

Rounded

Read-only property. A rounded copy of this Vector. Does not alter this Vector.A rounded copy of this Vector.

FlooredX

Read-only property. Returns the greatest integer that is not greater than the X value of this Vector.A int value that represents the X value of this Vector.

FlooredY

Read-only property. Returns the greatest integer that is not greater than the Y value of this Vector.A int value that represents the Y value of this Vector.

Floored

Read-only property. A floored copy of this Vector. Does not alter this Vector.A floored copy of this Vector.

CeilingedX

Read-only property. Returns the lowest integer that is not less than the X value of this Vector.A int value that represents the X value of this Vector.

CeilingedY

Read-only property. Returns the lowest integer that is not less than the Y value of this Vector.A int value that represents the Y value of this Vector.

Ceilinged

Read-only property. A ceiling:ed copy of this Vector. Does not alter this Vector.A ceiling:ed copy of this Vector.

Magnitude

Read-only property. The magnitude of this Vector.A float describing the magnitude.

Largest

Read-only property. The absolute largest of the two elements. Will always be positive.A float describing the largest value of the two, but not the magnitude.

Smallest

Read-only property. The absolute smallest of the two elements. Will always be positive.A float describing the smallest value of the two, but not the magnitude.

Normalized

Read-only property. A Vector that has the same direction as this but with a magnitude of 1.0.

Perpendicular

Read-only property. A Vector that is perpendicular to this, rotated PI/2.

AbsRadAngle

Read-only property. Get this Vector's absolute angle in radians. e.g: when x = 1, y = 0, the value returned here will be 0. x = 0, y = 1 yields -pi/2 here.The absolute angle in radians.

AbsDegAngle

Read-only property. Get this Vector's absolute angle in degrees. e.g: when x = 1, y = 0, the value returned here will be 0. x = 0, y = 1 yields -90 here.The absolute angle in degrees.


Functions

SetMagnitude

Sets the magnitude of this Vector and keeps its angle intact.

Arguments:

  • A float value that the magnitude will be set to.

Return value:

A reference to this after the change.


GetXFlipped

Gets a Vector identical to this except that its X component is flipped.

Arguments:

  • Whether to flip the X axis of the return vector or not.

Return value:

A copy of this vector with flipped X axis.


GetYFlipped

Gets a Vector identical to this except that its Y component is flipped.

Arguments:

  • Whether to flip the Y axis of the return vector or not.

Return value:

A copy of this vector with flipped Y axis.


CapMagnitude

Caps the magnitude of this Vector to a max value and keeps its angle intact.

Arguments:

  • A float value that the magnitude will be capped by.

Return value:

A reference to this after the change.


FlipX

Flips the X element of this Vector.

Arguments:

  • Whether or not to flip the X element or not.

Return value:

None.


FlipY

Flips the Y element of this Vector.

Arguments:

  • Whether or not to flip the Y element or not.

Return value:

None.


IsZero

Indicates whether both x and y components of this Vector are 0;

Arguments:

  • None.

Return value:

Whether both x and y components of this Vector are 0.


IsOpposedTo

Indicates whether the x and y components of this Vector each have opposite signs to their corresponding components of a passed in Vector.

Arguments:

  • The Vector to compare with.

Return value:

Whether both x and y components of this Vector are 0.


Dot

Returns the dot product of this Vector and the passed in Vector.

Arguments:

  • The Vector which will be the rhs operand of the dot product operation.

Return value:

The resulting dot product scalar float.


Cross

Returns the 2D cross product of this Vector and the passed in Vector. This is really the area of the parallellogram that the two vectors form.

Arguments:

  • The Vector which will be the rhs operand of the cross product operation.

Return value:

The resulting 2d cross product parallellogram area.


Round

Rounds the X and Y values of this Vector upwards. E.g. 0.49 -> 0.0 and 0.5 -> 1.0.

Arguments:

  • None.

Return value:

None.


ToHalf

Sets the X and Y of this Vector to the nearest half value. E.g. 1.0 -> 1.5 and 0.9 -> 0.5.

Arguments:

  • None.

Return value:

None.


Floor

Sets the X and Y of this Vector.to the greatest integers that are not greater than their original values. E.g. -1.02 becomes -2.0.

Arguments:

  • None.

Return value:

None.


Ceiling

Sets the X and Y of this Vector.to the lowest integers that are not less than their original values. E.g. -1.02 becomes -1.0.

Arguments:

  • None.

Return value:

None.


Normalize

Scales this vector to have the same direction but a magnitude of 1.0.

Arguments:

  • None.

Return value:

Vector reference to this after the operation.


Perpendicularize

Makes this vector perpendicular to its previous state, rotated PI/2. Much faster than RadRotate by PI/2.

Arguments:

  • None.

Return value:

Vector reference to this after the operation.


Reset

Sets both the X and Y of this Vector.to zero.

Arguments:

  • None.

Return value:

None.


RadRotate

Rotate this Vector relatively by an angle in radians.

Arguments:

  • The angle in radians to rotate by. Positive angles rotate counter- clockwise, and negative angles clockwise.

Return value:

This vector, rotated.


DegRotate

Rotate this Vector relatively by an angle in degrees.

Arguments:

  • The angle in degrees to rotate by. Positive angles rotate counter- clockwise, and negative angles clockwise.

Return value:

This vector, rotated.


DegRotate

Rotate this Vector around itself by a relative rotation in degrees.

Arguments:

  • The angle in degrees to rotate. Positive is counter clockwise, and negative is clockwise rotation.

Return value:

None.


AbsRotateTo

Set this Vector to an absolute rotation based on the absolute rotation of another Vector.

Arguments:

  • The reference Vector whose absolute angle from positive X (0 degrees) this Vector will be rotated to.

Return value:

This vector, rotated.


SetXY

Sets both the X and Y values of this Vector.

Arguments:

  • Two float values that the X and Y value will be set to, respectively.

Return value:

None.


Go back to Class Index

Personal tools