xrd-math

xrd-math

Functions

Types and Values

#define M_PI

Includes

#include <xrd.h>

Description

Functions

xrd_math_point_matrix_distance ()

float
xrd_math_point_matrix_distance (graphene_point3d_t *intersection_point,
                                graphene_matrix_t *pose);

xrd_math_get_rotation_angles ()

void
xrd_math_get_rotation_angles (graphene_vec3_t *direction,
                              float *azimuth,
                              float *inclination);

Calculate spherical angles from a direction vector with the direction vector's origin as the origin of the sphere.

Note that the distance (sphere radius) is not calculated. For converting between spherical and 3D coordinates, the caller needs to keep track of it.

Parameters

direction

a direction vector

 

azimuth

clockwise angle in deg around the y axis, starting at -z: "left-right" component.

 

inclination

upwards angle in deg from the xz plane: "up-down" component.

 

xrd_math_matrix_set_translation_point ()

void
xrd_math_matrix_set_translation_point (graphene_matrix_t *matrix,
                                       graphene_point3d_t *point);

xrd_math_matrix_set_translation_vec ()

void
xrd_math_matrix_set_translation_vec (graphene_matrix_t *matrix,
                                     graphene_vec3_t *vec);

xrd_math_intersect_lines_2d ()

gboolean
xrd_math_intersect_lines_2d (graphene_point_t *p0,
                             graphene_point_t *p1,
                             graphene_point_t *p2,
                             graphene_point_t *p3,
                             graphene_point_t *intersection);

Parameters

p0

The first point of the first line.

 

p1

The second point of the first line.

 

p2

The first point of the second line.

 

p3

The second point of the second line.

 

intersection

The resulting intersection point, if the lines intersect.

 

Returns

TRUE if the lines intersect, else FALSE.

2 lines are given by 2 consecutive (x,y) points each. Based on an algorithm in Andre LeMothe's "Tricks of the Windows Game Programming Gurus". Implementation from https://stackoverflow.com/a/1968345

xrd_math_clamp_towards_zero_2d ()

gboolean
xrd_math_clamp_towards_zero_2d (graphene_point_t *min,
                                graphene_point_t *max,
                                graphene_point_t *point,
                                graphene_point_t *clamped);

Parameters

min

The (x,y) limit at the bottom left.

 

max

The (x,y) limit at the top right.

 

point

An (x,y) point, will be clamped if outside the min, max limits.

 

clamped

The clamped point, if the point was outside the limits.

 

Returns

TRUE if the point was clamped, else FALSE.

The bottom left "min" and top right "max" limits define a rectangle. Clamp a value to the borders of this rectangle such that both x and y go towards zero, until a rectangle border is hit.

xrd_math_sphere_to_3d_coords ()

void
xrd_math_sphere_to_3d_coords (float azimuth,
                              float inclination,
                              float distance,
                              graphene_point3d_t *point);

Parameters

azimuth

rotation around y axis, starting at -z. "left-right" component.

 

inclination

rotation upwards from xz plane. "up-down" component".

 

distance

the radius of the sphere

 

point

the resulting point in 3D space on the surface of a sphere around (0,0,0) with distance .

 

Types and Values

M_PI

#define M_PI 3.14159265358979323846