Vec3

Represent a mathematical 3-dimensional vector.

struct Vec3 (
T
) {}

Constructors

this
this(T x_, T y_, T z_)
this(Vec2!T xy_, T z_)
this(T x_, Vec2!T yz_)

Build a new 3-dimensional vector.

Members

Functions

abs
Vec3!T abs()

Remove negative components.

ceil
Vec3!T ceil()

Round up the values.

clamp
Vec3!T clamp(Vec3!T min, Vec3!T max)

Bounds the vector between those two.

distance
T distance(Vec3!T v)

The distance between this point and the other one.

distanceSquared
T distanceSquared(Vec3!T v)

The distance between this point and the other one squared. Not square rooted, so no crash and more efficient.

floor
Vec3!T floor()

Truncate the values.

isBetween
bool isBetween(Vec3!T min, Vec3!T max)

Is this vector between those boundaries ?

length
T length()

The total length of this vector.

lengthSquared
T lengthSquared()

The squared length of this vector. Can be null, and more efficiant than length.

lerp
Vec3!T lerp(Vec3!T end, float t)

Returns an interpolated vector from this vector to the end vector by a factor. \ Does not modify this vector.

max
Vec3!T max(Vec3!T v)

The larger vector possible between the two.

min
Vec3!T min(Vec3!T v)

The smaller vector possible between the two.

normalize
void normalize()

Transform this vector in a unit vector.

normalized
Vec3!T normalized()

Returns a unit vector from this one without modifying this one.

opBinary
Vec3!T opBinary(Vec3!T v)
Vec3!T opBinary(T s)
opBinaryRight
Vec3!T opBinaryRight(T s)
opCast
Vec3!U opCast()

Operators.

opEquals
bool opEquals(Vec3!T v)
opOpAssign
Vec3!T opOpAssign(Vec3!T v)
Vec3!T opOpAssign(T s)
opUnary
Vec3!T opUnary()

Operators.

round
Vec3!T round()

Round the values to the nearest integer.

set
void set(T x_, T y_, T z_)
void set(Vec2!T xy_, T z_)
void set(T x_, Vec2!T yz_)

Changes {x, y, z}

sum
T sum()

Adds x, y and z.

Manifest constants

bottom
enum bottom;

{0, 0, -1} vector.

bottom
enum bottom;

{0, 0, -1} vector.

down
enum down;

{0, -1, 0} vector.

down
enum down;

{0, -1, 0} vector.

half
enum half;

{0.5, 0.5, 0.5} vector. Its length is not 0.5 !

left
enum left;

{-1, 0, 0} vector.

left
enum left;

{-1, 0, 0} vector.

one
enum one;

{1, 1, 1} vector. Its length is not one !

one
enum one;

{1, 1, 1} vector. Its length is not one !

one
enum one;

{1, 1, 1} vector. Its length is not one !

right
enum right;

{1, 0, 0} vector.

right
enum right;

{1, 0, 0} vector.

top
enum top;

{0, 0, 1} vector.

top
enum top;

{0, 0, 1} vector.

up
enum up;

{0, 1, 0} vector.

up
enum up;

{0, 1, 0} vector.

zero
enum zero;

Null vector.

zero
enum zero;

Null vector.

zero
enum zero;

Null vector.

Properties

xy
Vec2!T xy [@property getter]
Vec2!T xy [@property setter]

Return a 2-dimensional vector with {x, y}

xz
Vec2!T xz [@property getter]
Vec2!T xz [@property setter]

Return a 2-dimensional vector with {x, z}

yz
Vec2!T yz [@property getter]
Vec2!T yz [@property setter]

Return a 2-dimensional vector with {y, z}

Variables

x
T x;

x-axis coordinate.

y
T y;

y-axis coordinate.

z
T z;

z-axis coordinate.

Meta