Skip to content

Make naming more consistent and concise #146

@bvisness

Description

@bvisness

Handmade Math is too verbose right now. We want our names to be distinct and not conflict with other libraries, but nobody wants to read math expressions full of HMM_MultiplyMat4ByVec4. We should follow a more terse naming scheme.

Additionally, every part of Handmade Math's API should be prefixed with HMM_. Nothing will be hmm_ and nothing will be bare. HMM_ is our namespace and we must stick to it.

  • Types will be CamelCased for consistency:
    • Vectors: HMM_Vec2, HMM_Vec3, HMM_Vec4
    • Matrices: HMM_Mat2, HMM_Mat3, HMM_Mat4
    • Quaternions: HMM_Quat (four letter gang)
  • All references to data types in in function names must use single-letter forms:
    • Vectors: V2, V3, V4
    • Matrices: M2, M3, M4
    • Quaternions: Q
    • Floats: F
    • Ints: I
  • Common operations used in expressions should use short names:
    • Arithmetic: Add, Sub, Mul, Div
    • Comparison: Eq
    • Vector operations: Len, Norm. Dot and Cross can stay the same. (Norm I think is debatable, since "norm" already has a different meaning, but I really hate reading expressions full of "normalize" or "normalized".)
    • Any inverse: Inv
    • Square root & inverse square root: Sqrt, InvSqrt
  • Major transformations and projections can keep their full names: Translate, Rotate, Scale, Orthographic, Perspective, etc. These are not used commonly enough in dense expressions to be worth a terse name.

Examples:

  • HMM_MultiplyMat4ByVec4 -> HMM_MulM4V4
  • HMM_MultiplyVec3f -> HMM_MulV3F
  • HMM_EqualsVec4 -> HMM_EqV4
  • HMM_LengthVec3 -> HMM_LenV3
  • HMM_NormalizeVec3 -> HMM_NormV3 (In my opinion, calling it "NormV3" instead of "V3Norm" dodges the issue of "norm" meaning "length".)

Renaming the types will be moderately more annoying for those who want to upgrade due to the conflict with existing "constructor" functions like HMM_Vec3. However, they can first find and replace HMM_Vec3 with HMM_V3 before finding and replacing hmm_vec3 with HMM_Vec3. Not the end of the world; the process can still be automated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions