next up previous contents index
Next: Straight Rays in 3D-Space Up: Basic Data Types for Previous: Basic Data Types for   Contents   Index


Points in 3D-Space ( d3_point )

Definition

An instance of the data type d3_point is a point in the three-dimensional space R3. We use (x, y, z) to denote a point with first (or x-) coordinate x, second (or y-) coordinate y, and third (or z-) coordinate z.

#include < LEDA/geo/d3_point.h >

Creation

d3_point p introduces a variable p of type d3_point initialized to the point (0, 0, 0).

d3_point p(double x, double y, double z)
    introduces a variable p of type d3_point initialized to the point (x, y, z).

d3_point p(vector v) introduces a variable p of type d3_point initialized to the point (v[0], v[1], v[2]).
Precondition v.dim() = 3.

Operations

double p.xcoord() returns the first coordinate of p.

double p.ycoord() returns the second coordinate of p.

double p.zcoord() returns the third coordinate of p.

vector p.to_vector() returns the vector $\vec{{xyz}}\,$.

point p.project_xy() returns p projected into the xy-plane.

point p.project_yz() returns p projected into the yz-plane.

point p.project_xz() returns p projected into the xz-plane.

double p.sqr_dist(const d3_point& q)
    returns the square of the Euclidean distance between p and q.

double p.xdist(const d3_point& q)
    returns the x-distance between p and q.

double p.ydist(const d3_point& q)
    returns the y-distance between p and q.

double p.zdist(const d3_point& q)
    returns the z-distance between p and q.

double p.distance(const d3_point& q)
    returns the Euclidean distance between p and q.

double p.distance() returns the Euclidean distance between p and the origin.

d3_point p.translate(double dx, double dy, double dz)
    returns p translated by vector (dx, dy, dz).

d3_point p.translate(const vector& v)
    returns p+ v, i.e., p translated by vector v.
Precondition v.dim() = 3.

d3_point p + const vector& v returns p translated by vector v.

d3_point p - const vector& v returns p translated by vector - v.

d3_point p.reflect(const d3_point& q, const d3_point& r, const d3_point& s)
    returns p reflected across the plane passing through q, r and s.

d3_point p.reflect(const d3_point& q)
    returns p reflected across point q.

d3_point p.rotate_around_axis(int a, double phi)
    returns p rotated by angle phi around the x-axis if a = 1, aournd the y-axis if a = 1, or around the z-axis if a = 2.

d3_point p.rotate_around_vector(const vector& u, double phi)
    returns p rotated by angle phi around the axis defined by vector u.

d3_point p.cartesian_to_polar() returns p converted to polar coordinates.

d3_point p.polar_to_cartesian() returns p converted to cartesian coordinates.

vector p - const d3_point& q returns the difference vector of the coordinates.

ostream& ostream& O « const d3_point& p
    writes p to output stream O.

istream& istream& I » d3_point& p reads the coordinates of p (three double numbers) from input stream I.

Non-Member Functions

int cmp_distances(const d3_point& p1, const d3_point& p2, const d3_point& p3, const d3_point& p4)
    compares the distances (p1,p2) and (p3,p4). Returns +1 (-1) if distance (p1,p2) is larger (smaller) than distance (p3,p4), otherwise 0.

d3_point center(const d3_point& a, const d3_point& b)
    returns the center of a and b, i.e. a + $\vec{{ab}}\,$/2.

d3_point midpoint(const d3_point& a, const d3_point& b)
    returns the center of a and b.

int orientation(const d3_point& a, const d3_point& b, const d3_point& c, const d3_point& d)
    computes the orientation of points a, b, c, and d as the sign of the determinant

$\left\vert\begin{array}{cccc} 1 & 1 & 1 & 1\\
a_x & b_x & c_x & d_x\\
a_y & b_y & c_y & d_y\\
a_z & b_z & c_z & d_z
\end{array} \right\vert$

int orientation_xy(const d3_point& a, const d3_point& b, const d3_point& c)
    returns the orientation of the projections of a, b and c into the xy-plane.

int orientation_yz(const d3_point& a, const d3_point& b, const d3_point& c)
    returns the orientation of the projections of a, b and c into the yz-plane.

int orientation_xz(const d3_point& a, const d3_point& b, const d3_point& c)
    returns the orientation of the projections of a, b and c into the xz-plane.

double volume(const d3_point& a, const d3_point& b, const d3_point& c, const d3_point& d)
    computes the signed volume of the simplex determined by a,b, c, and d, positive if orientation(a, b, c, d ) > 0 and negative otherwise.

bool collinear(const d3_point& a, const d3_point& b, const d3_point& c)
    returns true if points a, b, c are collinear and false otherwise.

bool coplanar(const d3_point& a, const d3_point& b, const d3_point& c, const d3_point& d)
    returns true if points a, b, c, d are coplanar and false otherwise.

int side_of_sphere(const d3_point& a, const d3_point& b, const d3_point& c, const d3_point& d, const d3_point& x)
    returns +1 (-1) if point x lies on the positive (negative) side of the oriented sphere through points a, b, c, and d, and 0 if x is contained in this sphere.

int region_of_sphere(const d3_point& a, const d3_point& b, const d3_point& c, const d3_point& d, const d3_point& x)
    determines whether the point x lies inside (= + 1), on (= 0), or outside (= - 1) the sphere through points a, b, c, d, (equivalent to orientation(a,b,c,d) * side_of_sphere(a,b,c,d,x))
Precondition orientation(A)! = 0

bool contained_in_simplex(const d3_point& a, const d3_point& b, const d3_point& c, const d3_point& d, const d3_point& x)
    determines whether x is contained in the simplex spanned by the points a, b, c, d.
Precondition a, b, c, d are affinely independent.

bool contained_in_simplex(const array<d3_point>& A, const d3_point& x)
    determines whether x is contained in the simplex spanned by the points in A.
Precondition A must have size < = 4 and the points in A must be affinely independent.

bool contained_in_affine_hull(const list<d3_point>& L, const d3_point& x)
    determines whether x is contained in the affine hull of the points in L.

bool contained_in_affine_hull(const array<d3_point>& A, const d3_point& x)
    determines whether x is contained in the affine hull of the points in A.

int affine_rank(const array<d3_point>& L)
    computes the affine rank of the points in L.

int affine_rank(const array<d3_point>& A)
    computes the affine rank of the points in A.

bool affinely_independent(const list<d3_point>& L)
    decides whether the points in A are affinely independent.

bool affinely_independent(const array<d3_point>& A)
    decides whether the points in A are affinely independent.

bool inside_sphere(const d3_point& a, const d3_point& b, const d3_point& c, const d3_point& d, const d3_point& e)
    returns true if point e lies in the interior of the sphere through points a, b, c, and d, and false otherwise.

bool outside_sphere(const d3_point& a, const d3_point& b, const d3_point& c, const d3_point& d, const d3_point& e)
    returns true if point e lies in the exterior of the sphere through points a, b, c, and d, and false otherwise.

bool on_sphere(const d3_point& a, const d3_point& b, const d3_point& c, const d3_point& d, const d3_point& e)
    returns true if a, b, c, d, and e lie on a common sphere.

d3_point point_on_positive_side(const d3_point& a, const d3_point& b, const d3_point& c)
    returns a point d with orientation(a, b, c, d ) > 0.


next up previous contents index
Next: Straight Rays in 3D-Space Up: Basic Data Types for Previous: Basic Data Types for   Contents   Index