#include <cmath>
#include <assert.h>
#include "Vector3.h"
#include "Point3.h"
#include "Matrix.h"


Go to the source code of this file.
Classes | |
| struct | LineSegment |
| Defines a line segment. More... | |
| struct | Ray |
| Defines a ray. More... | |
| struct | Plane |
| Defines an infinite planes. More... | |
| struct | ScreenRect |
| Defines a 2D rectangular region of screen space. More... | |
| struct | Sphere |
| Defines a sphere. More... | |
| struct | CubeDef |
| Defines a cube. More... | |
| struct | CubePlanes |
| Defines the planes of a cube. More... | |
| struct | CubeFrame |
| Defines the lines that make up a cube. More... | |
Functions | |
| template<class dataType, class timeType> | |
| dataType | Lerp (const dataType &d0, const dataType &d1, const timeType &t) |
| Linearly interpolates between two data points. | |
| template<class T> | |
| void | Swap (T &v1, T &v2) |
| Swaps the given values. | |
| template<class T> | |
| T | Clamp (const T &val, const T &low, const T &high) |
| Clamps a value to be in a given range. | |
| CubePlanes | CreatePlanes (const CubeDef &c) |
| Creates a CubePlanes structure from a CubeDef. | |
| CubeFrame | CreateFrame (const CubeDef &c) |
| Creates a CubeFrame from a CubeDef. | |
| bool | Inside (const Point3f &p, const Sphere &s) |
| Tests if a point is inside a sphere. | |
| bool | Inside (int x, int y, const ScreenRect &rect) |
| Tests if a point is inside a screen rectangle. | |
| int | Intersect (const LineSegment &line, const Plane &plane, float &t) |
| Finds the intersection point between the a line and a plane. | |
| int | Intersect (const Plane &p, const CubeFrame &c, Point3f points[6]) |
| Intersects a Plane with a Cube. | |
| int | Intersect (const LineSegment &line, const Sphere &s, Point3f points[2]) |
| Intersects a Line segment with a sphere. | |
| int | Intersect (const Ray &r, const Sphere &s, Point3f points[2]) |
| Intersects a Ray with a sphere. | |
| Point3f | Average (const Point3f *points, int n) |
| Computes the average of a set of points. | |
| float | ReferanceAngle (const Vector3f &ref, const Vector3f &v1, const Vector3f &v2) |
| Computes the angle between two vectors and a mutaully perpendicular referance vector. | |
| void | SortPoints (Point3f *points, int n, const Vector3f &normal) |
| Sorts a set of points into cw or ccw order. | |
Definition in file MathCommon.h.
Computes the average of a set of points.
| [in] | points | the points. |
| [in] | n | the number of points. |
Definition at line 416 of file MathCommon.h.
Referenced by SortPoints().
| T Clamp | ( | const T & | val, | |
| const T & | low, | |||
| const T & | high | |||
| ) | [inline] |
Clamps a value to be in a given range.
| [in] | val | the value to clamp. |
| [in] | low | the low end of the range. |
| [in] | high | the high end of the range. |
Definition at line 154 of file MathCommon.h.
Referenced by TransferFunctionPlot::MouseMove().
Creates a CubeFrame from a CubeDef.
| [in] | c | the cube. |
Definition at line 195 of file MathCommon.h.
References CubeDef::c, CubeDef::dim, CubeFrame::line, LineSegment::p1, and LineSegment::p2.
Referenced by Cube::Init(), and RTVolumeRenderer::RTVolumeRenderer().
| CubePlanes CreatePlanes | ( | const CubeDef & | c | ) | [inline] |
Creates a CubePlanes structure from a CubeDef.
| [in] | c | the cube. |
Definition at line 170 of file MathCommon.h.
References CubeDef::dim, Plane::n, Plane::p, and CubePlanes::plane.
Referenced by Cube::Init().
| bool Inside | ( | int | x, | |
| int | y, | |||
| const ScreenRect & | rect | |||
| ) | [inline] |
Tests if a point is inside a screen rectangle.
| [in] | x | the x coordinate point. |
| [in] | y | the y coordinate point. |
| [in] | rect | the rectangle. |
Definition at line 249 of file MathCommon.h.
References ScreenRect::x1, ScreenRect::x2, and ScreenRect::y2.
Tests if a point is inside a sphere.
| [in] | p | the point. |
| [in] | s | the sphere. |
Definition at line 234 of file MathCommon.h.
References Sphere::c, Sphere::r, and Vector3< T >::SquaredLength().
Referenced by TransferFunctionPlot::SelectPoint(), and Camera::Zoom().
| int Intersect | ( | const LineSegment & | line, | |
| const Sphere & | s, | |||
| Point3f | points[2] | |||
| ) | [inline] |
Intersects a Line segment with a sphere.
| [in] | line | the line segment. |
| [in] | s | the line sphere. |
| [out] | points | the intersection points. |
Definition at line 313 of file MathCommon.h.
References Sphere::c, LineSegment::p1, LineSegment::p2, and Sphere::r.
Intersects a Plane with a Cube.
| [in] | p | the plane. |
| [in] | c | the cube frame. |
| [out] | points | the intersection points. |
Definition at line 285 of file MathCommon.h.
References Intersect(), CubeFrame::line, LineSegment::p1, and LineSegment::p2.
| int Intersect | ( | const LineSegment & | line, | |
| const Plane & | plane, | |||
| float & | t | |||
| ) | [inline] |
Finds the intersection point between the a line and a plane.
| [in] | line | the line. |
| [in] | plane | the plane. |
| [out] | t | the collision time. |
Definition at line 264 of file MathCommon.h.
References Plane::n, Plane::p, LineSegment::p1, and LineSegment::p2.
Referenced by Intersect(), and Camera::Zoom().
| dataType Lerp | ( | const dataType & | d0, | |
| const dataType & | d1, | |||
| const timeType & | t | |||
| ) | [inline] |
Linearly interpolates between two data points.
| dataType | the type of data that is being interpolated. | |
| timeType | the type of the value that controls the amount of interpolation. |
| [in] | d0 | the first data point. |
| [in] | d1 | the second data point. |
| [in] | t | the amount to interpolate. |
Definition at line 125 of file MathCommon.h.
Referenced by Intersect().
Computes the angle between two vectors and a mutaully perpendicular referance vector.
| [in] | ref | the referance vector. |
| [in] | v1 | the first vector. |
| [in] | v2 | the second vector. |
Definition at line 436 of file MathCommon.h.
References Vector3< T >::Length().
Referenced by SortPoints().
Sorts a set of points into cw or ccw order.
| [in,out] | points | the points to sort. |
| [in] | n | the number of points. Must be in the range [3,6]. |
| [in] | normal | the polygon normal that the points lie on. |
Definition at line 453 of file MathCommon.h.
References Average(), and ReferanceAngle().
| void Swap | ( | T & | v1, | |
| T & | v2 | |||
| ) | [inline] |
Swaps the given values.
| [in,out] | v1 | the first value. |
| [in,out] | v2 | the second value. |
Definition at line 137 of file MathCommon.h.
1.5.6