Vectors contain a trio of values – these values can be integers or floats. Many of RealFlow's parameters are stored as vector, e.g. position, velocity, rotation, scale, forces, and even RGB colours.
The default notation for introducing a new vector variable is vector = Vector.new(float x, float y, float z)
Vector Calculations
With vectors it is possible to perform standard algebraic operations like addition or subtraction
vectorA + vectorB = vectorC
vectorA - vectorB = vectorC
Be careful with vector multiplication, because it does not return another vector, but a floating number:
vectorA * vectorB = xA * xB + yA * yB + zA * zB = float
Special Calculations
With vectors you are able to perform specific operations like
Cross product: vectorA.cross(vectorB) = vectorC
Scaling/multiplication with a factor: vectorA.scale(float) = vectorC
Length: vectorA.module() = float
Distance: vectorA.distance(vectorB) = float
Getting Vector Components
In many case it is necessary to treat a vector's components individually:
x value = vector.getX()
y value = vector.getY()
z value = vector.getZ()
These values can be used in further calculations, e.g. to modify velocities or forces, and then reassembled to a new vector:
newVector = Vector.new(x new, y new, z new)