# Number3

A Number3 contains 3 number values (X, Y & Z). It can represent different things in 3D space (points, vectors, forces).

## Constructors

Creates a Number3 with values x, y and z.

local myNumber3 = Number3(1, 2, 3)

## Functions

Returns a copy of the Number3.

local n1 = Number3(1, 0, 0) local n2 = n1 -- n2 is not a copy but a direct reference to n1 n2.X = 10 print(n1.X) -- now n1.X == 10 -- using Copy: local n1 = Number3(1, 0, 0) local n2 = n1:Copy() -- n2 is a copy of n1, they're not the same Number3 n2.X = 10 print(n1.X) -- n1.X is still 1

Returns the dot product of both Number3s.

local n1 = Number3(1, 0, 0) local n2 = Number3(1, 0, 0) local dot = n1:Dot(n2)

Rotates the Number3 using euler angles in parameters (in radians).

local someNumber3 = Number3(0,0,1) local pi = 3.1415 someNumber3:Rotate(Number3(0,pi,0)) -- someNumber3 == Number3(0,0,-1), after a PI rotation around Y axis (180°)

## Properties

Reading Number3.SquaredLength is faster than reading Number3.Length.

This is the main reason why this attribute is exposed.

It can be used when comparing distances.

-- compare distances between objects local d2 = o1.Position - o2.Position local d3 = o1.Position - o3.Position if d2.SquaredLength < d3.SquaredLength then print("o1 is closer to o2") else print("o1 is closer to o3") end -- Using Length instead of SquaredLength would give the same results, -- but it would have to internally compute 2 square roots for nothing.