open class Vector3(var x: Float, var y: Float, var z: Float)
Vector3
(
v
)
|
Constructor for creating a Vector3 with all components set to the same value.
Signature
constructor(v: Float) Parameters v: Float
The value to set for all components.
Returns Vector3 |
Vector3
(
c
)
|
Constructor for creating a Vector3 from a Color object.
Signature
constructor(c: Color) Parameters c: Color
The Color object to create the Vector3 from.
Returns Vector3 |
Vector3
(
x
, y
, z
)
|
Signature
constructor(x: Float, y: Float, z: Float) Parameters x: Float
The x coordinate component.
y: Float
The y coordinate component.
z: Float
The z coordinate component.
Returns Vector3 |
x
: Float
[Get][Set] |
The x coordinate component.
Signature
open var x: Float |
y
: Float
[Get][Set] |
The y coordinate component.
Signature
open var y: Float |
z
: Float
[Get][Set] |
The z coordinate component.
Signature
open var z: Float |
add
(
v
)
| |
angleBetweenDegrees
(
v
)
|
Calculates the angle between two vectors in degrees.
Signature
fun angleBetweenDegrees(v: Vector3): Float Parameters Returns Float
The angle between the two vectors in degrees.
|
component1
()
|
Signature
operator fun component1(): Float Returns Float |
component2
()
|
Signature
operator fun component2(): Float Returns Float |
component3
()
|
Signature
operator fun component3(): Float Returns Float |
copy
()
| |
cross
(
other
)
| |
distanceTo
(
v
)
|
Calculates the distance between two vectors.
Signature
fun distanceTo(v: Vector3): Float Parameters Returns Float
The distance between the two vectors.
|
div
(
v
)
|
Divides a vector by a scalar.
Signature
inline operator fun div(v: Float): Vector3 Parameters v: Float
The scalar to divide by.
|
divide
(
v
)
|
Divides a vector by a scalar.
Signature
inline fun divide(v: Float): Vector3 Parameters v: Float
The scalar to divide by.
|
dot
(
v
)
|
Calculates the dot product of two vectors.
Signature
inline fun dot(v: Vector3): Float Parameters Returns Float
The dot product.
|
equals
(
other
)
|
Signature
open operator override fun equals(other: Any?): Boolean Parameters other: Any?Returns Boolean |
hashCode
()
|
Signature
open override fun hashCode(): Int Returns Int |
isWithinDistance
(
other
, distance
)
|
Checks if this position vector is within a specified Euclidean distance of another position vector.
This method uses squared distance internally for performance, avoiding a square root calculation. This is the recommended approach for position-based proximity checks in VR/AR applications.
Signature
fun isWithinDistance(other: Vector3, distance: Float): Boolean Parameters distance: Float
The maximum allowed Euclidean distance (in meters for world-space positions).
Returns Boolean
True if the Euclidean distance between the two vectors is less than or equal to distance.
|
length
()
|
Calculates the length (magnitude) of a vector.
Signature
fun length(): Float Returns Float
The length of the vector.
|
lerp
(
dest
, ratio
)
|
Linearly interpolates between two vectors.
Signature
fun lerp(dest: Vector3, ratio: Float): Vector3 Parameters ratio: Float
The interpolation ratio, where 0 means no interpolation (i.e., the current vector) and 1 means full interpolation (i.e., the destination vector).
|
max
(
v
)
| |
min
(
v
)
| |
minus
(
v
)
| |
multiply
(
v
)
| |
multiply
(
v
)
|
Multiplies a vector by a scalar.
Signature
inline fun multiply(v: Float): Vector3 Parameters v: Float
The scalar to multiply.
|
negate
()
| |
normalize
()
|
Normalizes a vector to have a length of 1
Signature
fun normalize(): Vector3 Returns Vector3
A new vector representing the normalization of this vector, or (0, 0, 0) if the length of this vector is 0.
|
plus
(
v
)
| |
setX
(
x
)
| |
setY
(
y
)
| |
setZ
(
z
)
| |
sub
(
v
)
| |
times
(
v
)
| |
times
(
v
)
|
Multiplies a vector by a scalar.
Signature
inline operator fun times(v: Float): Vector3 Parameters v: Float
The scalar to multiply.
|
toString
()
|
Returns a string representation of the vector.
Signature
open override fun toString(): String Returns String
A string representation of the vector in the format "(x, y, z)".
|
unaryMinus
()
|
Negates a vector.
Signature
inline operator fun unaryMinus(): Vector3 |