![]() |
Kale
|
Kale comes with a custom built linear algebra and math library. Since it is custom and does not rely on popular implementations, expect it to be slower and less powerful. If you need to squeeze every bit of performance out for whatever reason, you can look towards glm, BLAS, etc (that being said, this engine likely isn't the right one for you if you need this much performance).
Kale has templated Vectors with 2, 3, and 4 dimensions. Each vector class instance is named "Vector" + the number of dimensions + the initials of the underlying type. For example a vector of 2 floats is Vector2f. Or a vector with 3 size_t is Vector3st. The component member names of each vector class is listed below:
Each vector class has overloads for all basic arithmetic and boolean operations. They can also be printed via any Using the Logging System & Printing methods. You also don't have to worry about floating point errors as template specialization is used on floating types to account for epsilon. Some basic algebra/linear algebra methods exist as well such as dot products, cross products, etc. You can also cast a vector to another type using VectorN::cast(). Convenience methods exist for glsl style swizzling and clamping. Static methods also exist to get vectors with predefined values such as the max or min of the types, or values initialized to point at a certain directionl.
Kale also has templated matrices for any sizes. Not all sizes are well supported however, many methods are blocked via template specialization to only work on certain smaller sizes. The template class signature is Matrix<width, height, type>. All the matrix data is stored in the data member, don't be afraid to manually tinker with it if necessary. Printing of matrices is also supported via Using the Logging System & Printing methods.
You can access elements from the matrix like an array via the operator[size_t index] overload. You can also access it by column and row via the operator(size_t col, size_t row) overload. The operators use debug checks and throws if you access a value out of the bounds in debug mode. get method variants do not perform these checks in debug mode.
Matrices also support basic algebra operations such as addition, subtraction, or multiplication. Multiplication is template specialized based on size to be fast where possible. Transposing and some basic guassian elimination operations are also supported. You can also calculate the deteriment of the matrix via .det() which is also specialized based on the size of the matrix.
Transformation matrices inherit from the Matrix3f class. The Camera class is just an alias for the Transform class. Transformation matrices have all the matrix functionality along with convenience methods for translations, rotations, and scaling. Instead of using multiplication to transform vectors, you can use the transform method to directly transform Vector2fs. You can also use this method to transform some basic math geometries.
There are also available functions to convert from radians to degrees (radToDeg(float rad)) and vice versa (degToRad(float deg)). Normally when a method requires an angle as an argument, it will also take an AngleUnit enum value to determine what unit you are supplying with.
There are also functions defined to check if floating types are equal accounting for floating type error with epsilon. A few predefined constants exist for mathematical usage: