Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Vector Class Reference

Inherits ScriptObject.

Public Member Functions

 Vector ()
 
 Vector (Number x, Number y, Number z)
 
Number getX ()
 
 setX (Number x)
 
Number getY ()
 
 setY (Number y)
 
Number getZ ()
 
 setZ (Number z)
 
Number getCoordinate (Integer coordinate)
 
 setCoordinate (Integer coordinate, Number value)
 
 add (Vector value)
 
 add (Number x, Number y, Number z)
 
 subtract (Vector value)
 
 subtract (Number x, Number y, Number z)
 
 multiply (Number value)
 
 divide (Number value)
 
Boolean isNonZero (Number tolerance)
 
Boolean isZero (Number tolerance)
 
Number getXYAngle ()
 
Number getZAngle ()
 
Number getLength ()
 
Number getLength2 ()
 
 normalize ()
 
Vector getNormalized ()
 
 negate ()
 
Vector getNegated ()
 
Vector getAbsolute ()
 
Number getMinimum ()
 
Number getMaximum ()
 
String toString ()
 
Vector toDeg ()
 
Vector toRad ()
 

Static Public Member Functions

static Vector sum (Vector left, Vector right)
 
static Vector diff (Vector left, Vector right)
 
static Vector product (Vector left, Number right)
 
static Number dot (Vector left, Vector right)
 
static Number getAngle (Vector v1, Vector v2)
 
static Vector cross (Vector left, Vector right)
 
static Number getDistance (Vector left, Vector right)
 
static Number getDistance2 (Vector left, Vector right)
 
static Vector lerp (Vector left, Vector right, Number u)
 
static Boolean areParallel (Vector a, Vector b, Number tolerance)
 
static Boolean arePerpendicular (Vector a, Vector b, Number tolerance)
 
static Boolean areSameDirection (Vector a, Vector b, Number tolerance)
 
static Boolean areDifferent (Vector a, Vector b, Number tolerance)
 
static Number pointLineDistance (Vector point, Vector start, Vector end)
 
static Number pointSegmentDistance (Vector point, Vector start, Vector end)
 
static Vector projectPointToLine (Vector point, Vector start, Vector end)
 
static Number pointPlaneDistance (Vector point, Vector planePoint, Vector planeNormal)
 
static Vector projectPointToPlane (Vector point, Vector planePoint, Vector planeNormal)
 
static Vector translatePoint (Vector point, Vector vector, Number distance)
 
static Vector getBySpherical (Number xyAngle, Number zAngle, Number radius)
 

Public Attributes

Number x
 The X coordinate.
 
Number y
 The Y coordinate.
 
Number z
 The Z coordinate.
 
Number length
 The length of the vector.
 
Number length2
 The square of the length of the vector.
 
Vector negated
 The negated vector.
 
Vector abs
 The vector with the absolute coordinates.
 
Vector normalized
 The vector normalized to length 1.
 

Detailed Description

A 3D vector (X, Y, and Z coordinates).

Constructor & Destructor Documentation

◆ Vector() [1/2]

Vector ( )

Constructs a (0, 0, 0) vector.

◆ Vector() [2/2]

Vector ( Number  x,
Number  y,
Number  z 
)

Constructs a vector with the specified x, y, and z coordinates.

Member Function Documentation

◆ add() [1/2]

add ( Vector  value)

Adds the specified vector.

◆ add() [2/2]

add ( Number  x,
Number  y,
Number  z 
)

Adds the specified X, Y, and Z coordinates.

◆ areDifferent()

static Boolean areDifferent ( Vector  a,
Vector  b,
Number  tolerance 
)
static

Returns true if two vectors are different.

Parameters
aFirst vector to compare.
bSecond vector to compare.
toleranceAn optional comparison tolerance/accuracy. If 'tolerance' is greater than or equal to 1 then 'tolerance' specifies the number of digits to the right of the decimal to truncate the vectors to prior to comparison.
Since
r51671

◆ areParallel()

static Boolean areParallel ( Vector  a,
Vector  b,
Number  tolerance 
)
static

Returns true if two vectors are parallel.

Parameters
aFirst vector to compare.
bSecond vector to compare.
toleranceAn optional comparison tolerance/accuracy. If 'tolerance' is greater than or equal to 1 then 'tolerance' specifies the number of digits to the right of the decimal to truncate the vectors to prior to comparison.
Since
r51671

◆ arePerpendicular()

static Boolean arePerpendicular ( Vector  a,
Vector  b,
Number  tolerance 
)
static

Returns true if two vectors are perpendicular.

Parameters
aFirst vector to compare.
bSecond vector to compare.
toleranceAn optional comparison tolerance/accuracy. If 'tolerance' is greater than or equal to 1 then 'tolerance' specifies the number of digits to the right of the decimal to truncate the vectors to prior to comparison.
Since
r51671

◆ areSameDirection()

static Boolean areSameDirection ( Vector  a,
Vector  b,
Number  tolerance 
)
static

Returns true if two vectors are in the same direction.

Parameters
aFirst vector to compare.
bSecond vector to compare.
toleranceAn optional comparison tolerance/accuracy. If 'tolerance' is greater than or equal to 1 then 'tolerance' specifies the number of digits to the right of the decimal to truncate the vectors to prior to comparison.
Since
r51671

◆ cross()

static Vector cross ( Vector  left,
Vector  right 
)
static

Returns the cross product of this vector and the specified vector.

◆ diff()

static Vector diff ( Vector  left,
Vector  right 
)
static

Returns the difference of the specified vectors.

◆ divide()

divide ( Number  value)

Divides the vector by the specified value.

◆ dot()

static Number dot ( Vector  left,
Vector  right 
)
static

Returns the dot product of this vector and the specified vector.

◆ getAbsolute()

Vector getAbsolute ( )

Returns the vector with the absolute values of the coordinates.

◆ getAngle()

static Number getAngle ( Vector  v1,
Vector  v2 
)
static

Returns the angle between the specified vectors.

◆ getBySpherical()

static Vector getBySpherical ( Number  xyAngle,
Number  zAngle,
Number  radius 
)
static

Returns the vector for the specified spherical coordinates.

◆ getCoordinate()

Number getCoordinate ( Integer  coordinate)

Returns the specified coordinate (0:X, 1:Y, and 2:Z).

◆ getDistance()

static Number getDistance ( Vector  left,
Vector  right 
)
static

Returns the distance between the specified vectors.

◆ getDistance2()

static Number getDistance2 ( Vector  left,
Vector  right 
)
static

Returns the square of the distance between the specified vectors.

◆ getLength()

Number getLength ( )

Returns the length of this vector.

◆ getLength2()

Number getLength2 ( )

Returns the square length of this vector.

◆ getMaximum()

Number getMaximum ( )

Returns the value for the maximum coordinate.

◆ getMinimum()

Number getMinimum ( )

Returns the value for the minimum coordinate.

◆ getNegated()

Vector getNegated ( )

Returns the negated vector.

◆ getNormalized()

Vector getNormalized ( )

Returns the normalized vector.

◆ getX()

Number getX ( )

Returns the X coordinate.

◆ getXYAngle()

Number getXYAngle ( )

Returns the angle in the X-Y plane (spherical coordinate).

◆ getY()

Number getY ( )

Returns the Y coordinate.

◆ getZ()

Number getZ ( )

Returns the Z coordinate.

◆ getZAngle()

Number getZAngle ( )

Returns the Z angle relative to the X-Y plane (spherical coordinate).

◆ isNonZero()

Boolean isNonZero ( Number  tolerance)

Returns true if the vector has non-zero length.

Parameters
toleranceAn optional comparison tolerance/accuracy. If 'tolerance' is greater than or equal to 1 then 'tolerance' specifies the number of digits to the right of the decimal to truncate the vector to prior to comparison.

'tolerance' is available:

Since
r51671

◆ isZero()

Boolean isZero ( Number  tolerance)

Returns true if the vector is zero length.

Parameters
toleranceAn optional comparison tolerance/accuracy. If 'tolerance' is greater than or equal to 1 then 'tolerance' specifies the number of digits to the right of the decimal to truncate the vector to prior to comparison.

'tolerance' is available:

Since
r51671

◆ lerp()

static Vector lerp ( Vector  left,
Vector  right,
Number  u 
)
static

Linear interpolation between the specified vectors. The U coordinate is clamped to the range [0; 1]. U equal to 0 and 1 corresponds to the left vector and the right vector, respectively.

◆ multiply()

multiply ( Number  value)

Multiplies the specified value.

◆ negate()

negate ( )

Negates the vector.

◆ normalize()

normalize ( )

Normalizes the vector.

◆ pointLineDistance()

static Number pointLineDistance ( Vector  point,
Vector  start,
Vector  end 
)
static

Returns the distance between a point and a line of infinite length.

Parameters
pointPoint used to calculate distance to line.
startFirst point on infinite line.
endSecond point on infinite line.
Since
r51671

◆ pointPlaneDistance()

static Number pointPlaneDistance ( Vector  point,
Vector  planePoint,
Vector  planeNormal 
)
static

Returns the distance between a point and a plane.

Parameters
pointPoint used to calculate the distance to plane.
planePointPoint on plane.
planeNormalVector normal to plane.
Since
r51671

◆ pointSegmentDistance()

static Number pointSegmentDistance ( Vector  point,
Vector  start,
Vector  end 
)
static

Returns the distance between a point and a line segment. If the projected point is outside of the line segment, then the distance to the closest end point of the line segment is returned.

Parameters
pointPoint used to calculate the distance to line.
startStart point of line segment.
endEnd point of line segment.
Since
r51671

◆ product()

static Vector product ( Vector  left,
Number  right 
)
static

Returns the product of the specified vector and number.

◆ projectPointToLine()

static Vector projectPointToLine ( Vector  point,
Vector  start,
Vector  end 
)
static

Projects a point to a line of infinite length.

Parameters
pointPoint to project onto line.
startFirst point on infinite line.
endSecond point on infinite line.
Since
r51671

◆ projectPointToPlane()

static Vector projectPointToPlane ( Vector  point,
Vector  planePoint,
Vector  planeNormal 
)
static

Projects a point to a plane.

Parameters
pointPoint to project onto plane.
planePointPoint on plane.
planeNormalVector normal to plane.
Since
r51671

◆ setCoordinate()

setCoordinate ( Integer  coordinate,
Number  value 
)

Sets the specified coordinate (0:X, 1:Y, and 2:Z).

◆ setX()

setX ( Number  x)

Sets the X coordinate.

◆ setY()

setY ( Number  y)

Sets the Y coordinate.

◆ setZ()

setZ ( Number  z)

Sets the Z coordinate.

◆ subtract() [1/2]

subtract ( Vector  value)

Subtracts the specified vector.

◆ subtract() [2/2]

subtract ( Number  x,
Number  y,
Number  z 
)

Subtracts the specified X, Y, and Z coordinates.

◆ sum()

static Vector sum ( Vector  left,
Vector  right 
)
static

Returns the sum of the specified vectors.

◆ toDeg()

Vector toDeg ( )

Returns the value converted from radians to degrees.

◆ toRad()

Vector toRad ( )

Returns the value converted from degrees to radians.

◆ toString()

String toString ( )

Converts the vector to a string (e.g. (1, 2, 3)).

◆ translatePoint()

static Vector translatePoint ( Vector  point,
Vector  vector,
Number  distance 
)
static

Translates a point along a vector at a given distance.

Parameters
pointPoint to translate.
vectorVector to translate point along.
distanceDistance to translate point.
Since
r51671


Generated by Autodesk, Inc. 31 January 2025
Copyright (c) 2012-2025 by Autodesk, Inc.