JOML-CI / JOML

A Java math library for OpenGL rendering calculations
MIT License
728 stars 104 forks source link

Scalar multiplication for quaternions #316

Closed kebiro closed 2 years ago

kebiro commented 2 years ago

Hi,

first of all, thanks for this library. I've really enjoyed working with it so far.

I've noticed that there is no scalar multiplication method for quaternions. It's trivial to implement (see Real-Time Rendering 4th Edition p. 77) so imo it should be provided (either as a mul overload or its own method), unless there is a specific reason for its absence.

For now I'm making do with an extension function:

fun Quaternionf.scalarMul(s: Float): Quaternionf {
    this.x *= s
    this.y *= s
    this.z *= s
    this.w *= s
    return this
}
httpdigest commented 2 years ago

Thanks for the suggestion! The method mul() has been added to the quaternion classes and published with the latest 1.10.5-SNAPSHOT.