Latest version:
Tramway SDK 0.0.9
Github
Quick links
Home
Get Started

Math


This part of the framework contains math stuff. Since we use the glm library, we don't really need to create any of our own math types, but I alisased the vector and matrix types into the tram namespace in order to increase the readability of the source code.

There's also a couple of constants, which have to do with the coordinate system that we're using, i.e. DIRECTION_FORWARD, DIRECTION_SIDE and DIRECTION_UP.

Other than that, this part of the framework contains a couple of random math functions which the glm library doesn't have. At least in C++ part of the framework.

Since glm is a C++ only library, I re-implemented some of the vector types in Lua, so that they can be used for scripting.

Scripting in Lua


Creating a vector and operations on a vector

vector = tram.math.vec3(420.0, -42.0, 4.20)

vector = vector + tram.math.vec3(69.0, -69.0, 6.9)
vector = vector + 69.0

print("My vector:", vector)

Creating a quaternion from euler angles and operations on it

rotation = tram.math.quat(vector)

rotation = rotation * rotation

Rotating a vector by a quaternion

vector = rotation * vector