Vector3
Function reference for c-vector3 calculate
Heads up!
This is the documentation for the c-vector3
command. If you mean to read the information on c-vector2
, go here.
The term vector in this document will describe a 3D vector.
3D vectors
A 3D vector is a representation of a point in three-dimensional space. You can express vectors in CalcBot with 3 or 6 components, which collectively express the magnitude and direction of the vector.
General
c-v3 c <expression>
Shorthand syntax for c-vector3 calculate
.
c-v3 m [r | d]
Shorthand syntax for switching trigonometric modes. c-vector2
and c-vector3
both share the same trigonometric mode.
Operators
All operators from c-calculate
and c-vector2 calculate
are available for use in c-vector3 calculate
:
not n
Negates n
. If n
is a truthy value, false (0) is returned. Otherwise, true (1) is returned.
n!
Take the factorial of n
. If n
is a vector, this operation will throw an error.
a ^ b
Raise a
to the power of b
. If b
is a vector, this operation will immediately throw an error. If a
is a vector, but b
is not an integer, this operation will also immediately throw an error. This operation will not return a complex number in any situation, unlike in c-calculate
.
a * b
Multiply a
and b
. When operating on two vectors, this operator returns the dot product of the two vectors. To compute the cross productof two vectors, see cross(v1, v2).
a / b
Divide a
by b
. If b
is a vector, this operation will immediately throw an error.
a % b
Divide a
by b
and return the remainder of the result. This is also known as modulus division, or remainder division. If either a
or b
is a vector, this operation will immediately throw an error.
a + b
Add a
and b
.
a - b
Subtract b
from a
.
a is b
Returns true (1) if a
is equal to b
.
a nis b
Returns true (1) if a
is not equal to b
.
a ais b
Returns true (1) if a
is approximately equal to b
. The difference between them must be less than 1 * 10 ^ -6
. For vectors, this operator will compare the x and y components separately.
This operator is intended to be used when comparing the results of certain mathematical operations that produce slightly imprecise results (like prime notation).
a anis b
Negates the behavior of the ais
operator.
a > b
Returns true (1) if a
is greater than b
.
a < b
Returns true (1) if a
is less than b
.
a >= b
Returns true (1) if a
is greater than or equal to b
.
a <= b
Returns true (1) if a
is less than or equal to b
.
a and b
Returns true if both a
and b
are truthy values.
a or b
Returns true if either a
or b
are truthy values.
Vector literals
(a, b, c)
Syntax for a three-dimensional three-component vector.
(a, b, c, d, e, f)
Syntax for a three-dimensional six-component vector. Vectors of this kind are implicitly converted to their component form when used with other operations during evaluation.
Vector constants
These constants will always be available everywhere in all of c-vector3
's children commands.
i
= (1, 0, 0)j
= (0, 1, 0)k
= (0, 0, 1)zero
= (0, 0, 0)
Modified Vector2 functions
All c-vector2
functions as described here are available to use in c-vector2 calculate
, and most of them have been adapted for use with c-vector3 calculate
. There are some differences, however:
Removed functions
These functions that are available in c-vector2 calculate
are not available in c-vector3 calculate
(and have been replaced with similar functions):
Unique functions
These functions are unique to c-vector3 calculate
:
z(v)
Returns the z
component of vector v
.
oct(v)
Returns the octant that vector v
's component's head lies in. If the head is on the x-axis, 9 is returned. If the head is on the y-axis, 10 is returned. If the head is on the z-axis, 11 is returned.
This function serves as the replacement for c-vector2 calculate
's quad(v) function.
dirx(v)
Returns the direction angle vector v
makes with the x-axis.
This function, along with diry(v) and dirz(v), serves as the replacement for c-vector2 calculate
's dir(v) function.
diry(v)
Returns the direction angle vector v
makes with the y-axis.
This function, along with dirx(v) and dirz(v), serves as the replacement for c-vector2 calculate's dir(v) function.
dirz(v)
Returns the direction angle vector v
makes with the z-axis.
This function, along with dirx(v) and diry(v), serves as the replacement for c-vector2 calculate's dir(v) function.
cross(v1, v2)
Returns the cross product of vectors v1
and v2
.
Last updated