Libprimis
Imprimis' 3D destroyable world engine
Loading...
Searching...
No Matches
geom.h File Reference

Physical geometry objects. More...

Go to the source code of this file.

Classes

struct  vec2
 two dimensional Cartesian vector object More...
 
struct  vec
 three dimensional Cartesian vector object More...
 
struct  std::hash< vec >
 
struct  bvec
 three dimensional Cartesian byte vector More...
 
struct  vec4< T >
 A four dimensional Cartesian-space vector template. More...
 
class  matrix3
 matrix3: 3x3 matrix comprised of three vec3 vectors arranged as follows: [ a1 b1 c1 a2 b2 c2 a3 b3 c3 ] More...
 
struct  matrix4x3
 floating point 4x3 matrix object defined as four column vectors, a-d takes the form as follows: [ a1 b1 c1 d1 (x) a2 b2 c2 d2 (y) a3 b3 c3 d3 ] (z) More...
 
struct  ivec
 
struct  std::hash< ivec >
 
struct  ivec2
 integer vector2 More...
 
struct  svec
 short integer three-vector object More...
 
struct  matrix4
 floating point 4x4 array object More...
 
struct  GenericVec2< T >
 
struct  GenericVec3< T >
 

Functions

bool raysphereintersect (const vec &center, float radius, const vec &o, const vec &ray, float &dist)
 
bool rayboxintersect (const vec &b, const vec &s, const vec &o, const vec &ray, float &dist, int &orient)
 
bool linecylinderintersect (const vec &from, const vec &to, const vec &start, const vec &end, float radius, float &dist)
 Determines whether a line segment intersects a specified cylinder.
 
int polyclip (const vec *in, int numin, const vec &dir, float below, float above, vec *out)
 
int mod360 (int angle)
 Returns the angle passed to it, clamped to 0...360.
 
const vec2sincosmod360 (int angle)
 Returns a vec2 containing (cos, sine) for a given integral angle.
 
float cos360 (int angle)
 Returns the cosine for an angle (in degrees)
 
float sin360 (int angle)
 Returns the sine for an angle (in degrees)
 
float tan360 (int angle)
 Returns the tangent for an angle (in degrees)
 
float cotan360 (int angle)
 Returns the cotangent for an angle (in degrees)
 

Variables

const int R [3] = {1, 2, 0}
 
const int C [3] = {2, 0, 1}
 
const int D [3] = {0, 1, 2}
 
const vec2 sincos360 []
 

Detailed Description

Physical geometry objects.

This file describes objects which represent concrete geometric constructions, such as vectors that represent 2D, 3D, and 4D Cartesian coordinates, as well as more complex geometric structures such as quaternions and matrices.

Function Documentation

◆ cos360()

float cos360 ( int angle)
inline

Returns the cosine for an angle (in degrees)

Must be within the bounds of 0...720. Uses a lookup table for integral values in degrees.

Parameters
anglethe angle to get the cosine of (in degrees)
Returns
the cosine of that angle

◆ cotan360()

float cotan360 ( int angle)
inline

Returns the cotangent for an angle (in degrees)

Must be within the bounds of 0...720. Uses a lookup table for integral values in degrees.

Parameters
anglethe angle to get the cotangent of (in degrees)
Returns
the cotangent of that angle

◆ linecylinderintersect()

bool linecylinderintersect ( const vec & from,
const vec & to,
const vec & start,
const vec & end,
float radius,
float & dist )
extern

Determines whether a line segment intersects a specified cylinder.

Calculates whether a specified line segment intersects a cylinder, defined by a line segment and a radius around it. Segments which intersect along an edge, face, or tangent to the curved surface are considered to be intersecting. A successful intersection will cause the function to return true.

Negative radii are handled the same as a positive radius of the same magnitude.

If the line segment is entirely within the boundaries of the cylinder, the segment is considered to be intersecting, with the intersection starting at the from location.

The distance along the line at which the segment intersects the cylinder is expressed as a value from 0 to 1 and returned through the reference parameter dist. If the segment is entirely within the cylinder, the segment's intersection distance is considered to be zero.

If no intersection with the cylinder is found, the dist value will be returned unchanged, and the function will return false.

Parameters
fromthe start point of the intersecting line segment
tothe end point of the intersecting line segment
startthe start point of the cylinder's axial line segment
endthe endpoint of the cylinder's axial line segment
radiusthe radius of the cylinder to be intersected
distthe value to set to the distance along the segment where intersection occured
Returns
true if the cylinder was intersected by the line segment
false if the cylinder and line segment did not intersect

◆ mod360()

int mod360 ( int angle)
inline

Returns the angle passed to it, clamped to 0...360.

Normalizes negative/large angles passed to it to the range [0,360).

Parameters
anglethe angle to parse
Returns
the angle clamped to 0...360

◆ sin360()

float sin360 ( int angle)
inline

Returns the sine for an angle (in degrees)

Must be within the bounds of 0...720. Uses a lookup table for integral values in degrees.

Parameters
anglethe angle to get the sine of (in degrees)
Returns
the sine of that angle

◆ sincosmod360()

const vec2 & sincosmod360 ( int angle)
inline

Returns a vec2 containing (cos, sine) for a given integral angle.

Parameters
anglethe angle to get the sine/cos value of
Returns
a vec2 containing the cosine and sine of the given angle

◆ tan360()

float tan360 ( int angle)
inline

Returns the tangent for an angle (in degrees)

Must be within the bounds of 0...720. Uses a lookup table for integral values in degrees.

Parameters
anglethe angle to get the tangent of (in degrees)
Returns
the tangent of that angle

Variable Documentation

◆ C

const int C[3] = {2, 0, 1}

col

◆ D

const int D[3] = {0, 1, 2}

depth

◆ R

const int R[3] = {1, 2, 0}

row

◆ sincos360

const vec2 sincos360[]
extern

a 721 element table of cosines, sines given integral values