Gama C Library
Gama C API Documentation
transform.h File Reference

Defines structures and functions for 3D transformations (position, rotation, scale). More...

#include "position.h"

Go to the source code of this file.

Data Structures

struct  gm3Transform
 Represents a 3D transformation, including position, rotation, and scale. More...

Functions

void gm3_pos_rotate (gm3Pos *res, const gm3Pos *rot)
 Rotates a gm3Pos vector by the given Euler angles (X, Y, Z).
void gm3_transform_pos (gm3Pos *p, const gm3Transform *t)
 Applies a gm3Transform to a gm3Pos vector.
gm3Transform gm3_transform ()
 Creates a new gm3Transform struct initialized to identity.

Variables

const gm3Transform gm3_default_transform
 A default gm3Transform instance.

Detailed Description

Defines structures and functions for 3D transformations (position, rotation, scale).

This file provides the gm3Transform structure to encapsulate the translation, rotation, and scaling of 3D objects, along with helper functions to apply these transformations to 3D points and vectors.

Function Documentation

◆ gm3_pos_rotate()

void gm3_pos_rotate ( gm3Pos * res,
const gm3Pos * rot )

Rotates a gm3Pos vector by the given Euler angles (X, Y, Z).

The rotation is applied sequentially around the X, then Y, then Z axes.

Parameters
resA pointer to the gm3Pos vector to rotate (modified in place).
rotA pointer to a gm3Pos containing the Euler angles (radians) for rotation around X, Y, and Z axes.

◆ gm3_transform()

gm3Transform gm3_transform ( )

Creates a new gm3Transform struct initialized to identity.

The position and rotation are set to zero, and scale is set to one.

Returns
A new identity gm3Transform instance.

◆ gm3_transform_pos()

void gm3_transform_pos ( gm3Pos * p,
const gm3Transform * t )

Applies a gm3Transform to a gm3Pos vector.

The transformation is applied in the order: scale, then rotate, then translate.

Parameters
pA pointer to the gm3Pos vector to transform (modified in place).
tA pointer to the gm3Transform to apply.

Variable Documentation

◆ gm3_default_transform

const gm3Transform gm3_default_transform
Initial value:
= {
.position = {0, 0, 20}, .rotation = {0}, .scale = {1, 1, 1}}

A default gm3Transform instance.

Initializes a transform with default position {0, 0, 20}, no rotation, and uniform scale {1, 1, 1}.