Skip to content
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
227 changes: 227 additions & 0 deletions content/en-us/reference/engine/libraries/vector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
name: vector
type: library
summary: |
A library of vector functions.
description: |
This library implements functionality for the vector type in addition to the built-in primitive operator support. It uses vectors with 3 components (x, y, and z).

Individual vector components can be accessed using the fields x or X, y or Y, z or Z. Since vector values are immutable, writes to individual components are not supported.
code_samples:
properties:
- name: vector.zero
type: vector
summary: Constant vector with all components set to 0.
description: Constant vector with all components set to 0.
tags:
code_samples:
- name: vector.one
type: vector
summary: Constant vector with all components set to 1.
description: Constant vector with all components set to 1.
tags:
code_samples:
functions:
- name: vector.create
summary: Creates a new vector with the given component values.
description: Creates a new vector with the given component values.
parameters:
- name: x
type: number
default:
summary: ''
- name: y
type: number
default:
summary: ''
- name: z
type: number
default:
summary: ''
returns:
- type: vector
summary: ''
tags:
code_samples:
- name: vector.magnitude
summary: Calculates the magnitude of a given vector.
description: Calculates the magnitude of a given vector.
parameters:
- name: vec
type: vector
default:
summary: ''
returns:
- type: number
summary: ''
tags:
code_samples:
- name: vector.normalize
summary: Computes the normalized version (unit vector) of a given vector.
description: Computes the normalized version (unit vector) of a given vector.
parameters:
- name: vec
type: vector
default:
summary: ''
returns:
- type: vector
summary: ''
tags:
code_samples:
- name: vector.cross
summary: Computes the cross product of two vectors.
description: Computes the cross product of two vectors.
parameters:
- name: vec1
type: vector
default:
summary: ''
- name: vec2
type: vector
default:
summary: ''
returns:
- type: vector
summary: ''
tags:
code_samples:
- name: vector.dot
summary: Computes the dot product of two vectors.
description: Computes the dot product of two vectors.
parameters:
- name: vec1
type: vector
default:
summary: ''
- name: vec2
type: vector
default:
summary: ''
returns:
- type: number
summary: ''
tags:
code_samples:
- name: vector.angle
summary: Computes the angle between two vectors in radians.
description: |
Computes the angle between two vectors in radians. The axis, if specified, is used to determine the sign of the angle.
parameters:
- name: vec1
type: vector
default:
summary: ''
- name: vec2
type: vector
default:
summary: ''
- name: axis
type: vector?
default:
summary: ''
returns:
- type: number
summary: ''
tags:
code_samples:
- name: vector.floor
summary: Applies `math.floor` to every component of the input vector.
description: Applies `math.floor` to every component of the input vector.
parameters:
- name: vec
type: vector
default:
summary: ''
returns:
- type: vector
summary: ''
tags:
code_samples:
- name: vector.ceil
summary: Applies `math.ceil` to every component of the input vector.
description: Applies `math.ceil` to every component of the input vector.
parameters:
- name: vec
type: vector
default:
summary: ''
returns:
- type: vector
summary: ''
tags:
code_samples:
- name: vector.abs
summary: Applies `math.abs` to every component of the input vector.
description: Applies `math.abs` to every component of the input vector.
parameters:
- name: vec
type: vector
default:
summary: ''
returns:
- type: vector
summary: ''
tags:
code_samples:
- name: vector.sign
summary: Applies `math.sign` to every component of the input vector.
description: Applies `math.sign` to every component of the input vector.
parameters:
- name: vec
type: vector
default:
summary: ''
returns:
- type: vector
summary: ''
tags:
code_samples:
- name: vector.clamp
summary: Applies `math.clamp` to every component of the input vector.
description: Applies `math.clamp` to every component of the input vector.
parameters:
- name: vec
type: vector
default:
summary: ''
- name: min
type: vector
default:
summary: ''
- name: max
type: vector
default:
summary: ''
returns:
- type: vector
summary: ''
tags:
code_samples:
- name: vector.max
summary: Applies `math.max` to the corresponding components of the input vectors.
description: |
Applies `math.max` to the corresponding components of the input vectors. Equivalent to `vector.create(math.max((...).x), math.max((...).y), math.max((...).z))`.
parameters:
- name: ...
type: vector
default:
summary: ''
returns:
- type: vector
summary: ''
tags:
code_samples:
- name: vector.min
summary: Applies `math.min` to the corresponding components of the input vectors.
description: |
Applies `math.min` to the corresponding components of the input vectors. Equivalent to `vector.create(math.min((...).x), math.min((...).y), math.min((...).z))`.
parameters:
- name: ...
type: vector
default:
summary: ''
returns:
- type: vector
summary: ''
tags:
code_samples:
Loading