#ifndef rdo_geometry_H #define rdo_geometry_H /* Extra geometry tools. */ #define rdo_geometry_H_COPYRIGHT "Copyright © 2008 Danillo Pereira and J. Stolfi, UNICAMP" /* Last edited on 2024-12-21 11:52:41 by stolfi */ #include #include typedef r3_t point3_t; /* A point of {R^3}. */ typedef r3_t vector3_t; /* A vector of {R^3}. */ double r3_dir_safe(r3_t *a); /* Normalizes the Euclidan length of {*a} to be 1.0, as {r3_dir(a,a)}; except that if {a} is {(0,0,0)} then it leaves {a} unchanged, instead of filling it with {NaN}s. Returns the original length of {a}. */ vector3_t rdo_geometry_pt_pt_dir(point3_t *p, point3_t *q); /* Unit vector pointing from {p} to {q}, or {(0,0,0)} if {p == q}. */ void rdo_geometry_ortho(vector3_t *a, vector3_t *b, vector3_t *r); /* Places in {*r} the component of {*b} that is orthogonal to {*a}. */ vector3_t rdo_geometry_vector3_from_polar(double theta, double phi); /* Unit vector that makes angle {theta} wiith the Z axis, and whose projection on the XY plane makes angle {phi} with the X axis. */ #define NOTNULL(p) NotNull((p),__FILE__,__LINE__) /* If the argument {p} is NULL, stops the program with an error message showing the current source location. Othwerwise returns {p}. !!! This macro should replace {notnull} in {affirm.h}. !!! */ void *NotNull(void *p, char *file, int line); /* If the argument {p} is NULL, stops the program with an error message including the source file anme {file} and line number {line}. Othwerwise returns {p}. */ #endif