mirror of https://github.com/CGAL/cgal
Remove the geometry files
This commit is contained in:
parent
fa7217c682
commit
5321a90c27
|
|
@ -1,153 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/*****************************************************************
|
|
||||||
* File: circle2d.h
|
|
||||||
* Synopsis:
|
|
||||||
* Basic 2-dimensional geometry
|
|
||||||
* Author: Shubin Zhao (shubinz@cs.nyu.edu), 2001.
|
|
||||||
*
|
|
||||||
*****************************************************************
|
|
||||||
* CORE Library Version 1.4 (July 2001)
|
|
||||||
* Chee Yap <yap@cs.nyu.edu>
|
|
||||||
* Chen Li <chenli@cs.nyu.edu>
|
|
||||||
* Zilin Du <zilin@cs.nyu.edu>
|
|
||||||
*
|
|
||||||
* Copyright (c) 1995, 1996, 1998, 1999, 2000, 2001 Exact Computation Project
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
#ifndef _CIRCLE2D_H
|
|
||||||
#define _CIRCLE2D_H
|
|
||||||
|
|
||||||
#include <CGAL/CORE/geom2d/point2d.h>
|
|
||||||
#include <CGAL/CORE/geom2d/line2d.h>
|
|
||||||
|
|
||||||
class Circle2d : public GeomObj {
|
|
||||||
|
|
||||||
/* An instance C of the data type circle is an oriented circle
|
|
||||||
in the plane passing through three points p1, p2, p3. The
|
|
||||||
orientation of C is equal to the orientation of the three defining
|
|
||||||
points. i.e. orientation(p1, p2, p3).
|
|
||||||
If \Labs{\{p1, p2, p3\}} = 1, C is the empty circle with center p1.
|
|
||||||
If p1, p2 and p3 are collinear, C is a straight line passing through
|
|
||||||
p1, p2 and p3 in this order and the center of C is undefined.
|
|
||||||
*/
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
Point2d p1; // the 3 points defining the circle
|
|
||||||
Point2d p2;
|
|
||||||
Point2d p3;
|
|
||||||
|
|
||||||
int orient; //orientation(p1, p2, p3)
|
|
||||||
|
|
||||||
Point2d* cp; //pointer to center
|
|
||||||
double * rp; //pointer to radius
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Circle2d( const Point2d& p1, const Point2d& p2, const Point2d& p3);
|
|
||||||
//initialized to the oriented circle through points p1, p2, p3
|
|
||||||
|
|
||||||
Circle2d(const Point2d& a, const Point2d& b0);
|
|
||||||
//initialized to the counter-clockwise oriented circle with center a
|
|
||||||
//passing through b0
|
|
||||||
|
|
||||||
Circle2d(const Point2d& p);
|
|
||||||
//initialized to the trivial circle with center p
|
|
||||||
|
|
||||||
Circle2d();
|
|
||||||
//initialized to the trivial circle with center (0,0)
|
|
||||||
|
|
||||||
Circle2d(const Point2d& c, double r);
|
|
||||||
//initialized to the circle with center c and radius r with positive
|
|
||||||
//(i.e. counter-clockwise) orientation
|
|
||||||
|
|
||||||
Circle2d(const Circle2d& c);
|
|
||||||
//copy constructor
|
|
||||||
|
|
||||||
virtual ~Circle2d();
|
|
||||||
|
|
||||||
Circle2d& operator=(const Circle2d& C);
|
|
||||||
|
|
||||||
//operations
|
|
||||||
|
|
||||||
Point2d center();
|
|
||||||
//return the center of the circle
|
|
||||||
|
|
||||||
double radius();
|
|
||||||
//returns the radius.
|
|
||||||
//precond: the orientation of the circle is not 0
|
|
||||||
|
|
||||||
Point2d point1() const { return p1; }
|
|
||||||
Point2d point2() const { return p2; }
|
|
||||||
Point2d point3() const { return p3; }
|
|
||||||
|
|
||||||
// Point2d point_on_circle(float alpha);
|
|
||||||
//returns a point p on the circle with angle of alpha
|
|
||||||
|
|
||||||
bool is_degerate() const { return orient == 0; }
|
|
||||||
//returns true if the defining points are collinear
|
|
||||||
|
|
||||||
bool is_trivial() const {return p1 == p2; }
|
|
||||||
//returns true if radius is zero
|
|
||||||
|
|
||||||
int orientation() const { return orient; }
|
|
||||||
|
|
||||||
int side_of(const Point2d& p) const;
|
|
||||||
// returns -1, +1 or 0 if p lies right of, left of or on the circle
|
|
||||||
// respectively
|
|
||||||
|
|
||||||
bool inside(const Point2d& p);
|
|
||||||
//returns true if p lies inside of the circle
|
|
||||||
|
|
||||||
bool outside(const Point2d& p);
|
|
||||||
|
|
||||||
bool contains(const Point2d& p) const ;
|
|
||||||
//returns true if p lies on the circle, false otherwise
|
|
||||||
|
|
||||||
double distance(const Point2d& p);
|
|
||||||
//returns the distance between p and the circle: distance to center - radius
|
|
||||||
|
|
||||||
double distance(const Line2d& l);
|
|
||||||
//returns the distance between l and the circle
|
|
||||||
//distance from center to l minus radius
|
|
||||||
|
|
||||||
double distance(Circle2d& D);
|
|
||||||
//returns the distance between this circle and circle D
|
|
||||||
//distance between two centers minus two radius
|
|
||||||
|
|
||||||
bool operator==(const Circle2d& D) const ;
|
|
||||||
bool operator!=(const Circle2d& D) const
|
|
||||||
{ return !operator==(D); }
|
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& out, Circle2d& c);
|
|
||||||
friend std::istream& operator>>(std::istream& in, Circle2d c); //?? Circle2d &
|
|
||||||
|
|
||||||
}; // class Circle2d
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,175 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/*****************************************************************
|
|
||||||
* File: line2d.h
|
|
||||||
* Synopsis:
|
|
||||||
* Basic 2-dimensional geometry
|
|
||||||
* Author: Shubin Zhao (shubinz@cs.nyu.edu), 2001.
|
|
||||||
*
|
|
||||||
*****************************************************************
|
|
||||||
* CORE Library Version 1.4 (July 2001)
|
|
||||||
* Chee Yap <yap@cs.nyu.edu>
|
|
||||||
* Chen Li <chenli@cs.nyu.edu>
|
|
||||||
* Zilin Du <zilin@cs.nyu.edu>
|
|
||||||
*
|
|
||||||
* Copyright (c) 1995, 1996, 1998, 1999, 2000, 2001 Exact Computation Project
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
#ifndef _LINE2D_H_
|
|
||||||
#define _LINE2D_H_
|
|
||||||
|
|
||||||
#include <CGAL/CORE/geom2d/point2d.h>
|
|
||||||
|
|
||||||
class Line2d : public GeomObj {
|
|
||||||
|
|
||||||
/* An instance l of the data type $line$ is a directed straight line
|
|
||||||
in the two dimensional plane. The angle between a right oriented
|
|
||||||
horizontal line and $l$ is called the direction of $l$.
|
|
||||||
*/
|
|
||||||
/* member Vector is not used in this class, it's intended for use in
|
|
||||||
the operator+,- etc
|
|
||||||
need to do: assure p0 != p1
|
|
||||||
*/
|
|
||||||
private:
|
|
||||||
|
|
||||||
Point2d p0;
|
|
||||||
Point2d p1;
|
|
||||||
Vector V;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* constructors
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
Line2d(const Point2d & p, const Vector &v);
|
|
||||||
// line initialized to pass through points p and p+v
|
|
||||||
|
|
||||||
Line2d(const Point2d &p, const Point2d &q);
|
|
||||||
//line is initialized to pass through points p and q directed from p to q
|
|
||||||
|
|
||||||
// Line2d(const point& p, double alpha);
|
|
||||||
//line passes through point p with direction alpha
|
|
||||||
|
|
||||||
Line2d(const double& a, const double& b, const double& c);
|
|
||||||
|
|
||||||
Line2d(const Line2d &);
|
|
||||||
|
|
||||||
Line2d();
|
|
||||||
//line passes through the origin with direction 0.
|
|
||||||
|
|
||||||
virtual ~Line2d() {}
|
|
||||||
/*************************************************************
|
|
||||||
* member functions
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
Vector direction() const { return p1-p0; }
|
|
||||||
// returns the direction as a vector
|
|
||||||
|
|
||||||
Point2d startPt() const { return p0; }
|
|
||||||
Point2d stopPt() const { return p1; }
|
|
||||||
|
|
||||||
double distance(Point2d q) const;
|
|
||||||
// returns the Euclidean distance between this line and point q
|
|
||||||
|
|
||||||
Point2d projection(const Point2d& p) const;
|
|
||||||
// returns the projection of p on this line
|
|
||||||
|
|
||||||
int orientation( const Point2d& p ) const;
|
|
||||||
// orientation of p0, p1 and p
|
|
||||||
|
|
||||||
// the sine/cosine of the angle made with positive x-direction
|
|
||||||
double sine() const { return (p1.Y() - p0.Y()) / p0.distance(p1); }
|
|
||||||
double cosine() const { return (p1.X() - p0.X()) / p0.distance(p1); }
|
|
||||||
|
|
||||||
Line2d rotate90( const Point2d& q)
|
|
||||||
{ return Line2d(startPt().rotate90(q), stopPt().rotate90(q)); }
|
|
||||||
|
|
||||||
double y_abs() const;
|
|
||||||
// returns the y-abscissa of the line
|
|
||||||
|
|
||||||
double slope() const ;
|
|
||||||
//precond: is not vertical
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* predicates
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
bool isVertical() const { return p0.X() == p1.X(); }
|
|
||||||
bool isHorizontal() const { return p0.Y() == p1.Y(); }
|
|
||||||
bool is_trivial() const {return p0 == p1; } //meaning for a line?
|
|
||||||
|
|
||||||
bool contains( const Point2d& p) const {
|
|
||||||
return orientation2d(p0, p1, p) == 0; }
|
|
||||||
bool isCoincident( const Line2d& g) const {
|
|
||||||
return contains(g.p0) && contains(g.p1); }
|
|
||||||
bool isParallel(const Line2d& l) const {
|
|
||||||
return det(V, l.direction()) == 0; }
|
|
||||||
|
|
||||||
bool operator==( const Line2d& g ) const { return isCoincident(g); }
|
|
||||||
bool operator!=( const Line2d& g ) const { return !operator==(g); }
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* intersection
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
int intersects(const Line2d& t) const;
|
|
||||||
// decides whether *this and t intersects
|
|
||||||
// return dim of intersection.
|
|
||||||
// return -1 if no intersection
|
|
||||||
|
|
||||||
GeomObj* intersection(const Line2d& g) const;
|
|
||||||
//if this line and g intersect in a single point, this point is
|
|
||||||
// assigned to p and the result is true, otherwise the result is false
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* angles and others
|
|
||||||
*************************************************************/
|
|
||||||
friend int orientation2d( const Line2d& l, const Point2d& p);
|
|
||||||
// computes the orientation (a, b, p), where a!=b and a and b appear
|
|
||||||
// in this order on line l
|
|
||||||
|
|
||||||
friend int cmp_slopes(const Line2d& l1, const Line2d& l2)
|
|
||||||
//l1.slope > l2.slope: +1; equal: 0; otherwise: -1
|
|
||||||
{
|
|
||||||
if (l1.slope() == l2.slope())
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return (l1.slope() > l2.slope()) ? +1 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* I/O
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
friend std::istream& operator>>(std::istream& in, Line2d& l);
|
|
||||||
friend std::ostream &operator<<(std::ostream & out, const Line2d & l);
|
|
||||||
}; // class Line2d
|
|
||||||
|
|
||||||
extern Line2d p_bisector(const Point2d& p, const Point2d& q);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,187 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/*****************************************************************
|
|
||||||
* File: point2d.h
|
|
||||||
* Synopsis:
|
|
||||||
* Basic 2-dimensional geometry
|
|
||||||
* Author: Shubin Zhao (shubinz@cs.nyu.edu), 2001.
|
|
||||||
*
|
|
||||||
*****************************************************************
|
|
||||||
* CORE Library Version 1.4 (July 2001)
|
|
||||||
* Chee Yap <yap@cs.nyu.edu>
|
|
||||||
* Chen Li <chenli@cs.nyu.edu>
|
|
||||||
* Zilin Du <zilin@cs.nyu.edu>
|
|
||||||
*
|
|
||||||
* Copyright (c) 1995, 1996, 1998, 1999, 2000, 2001 Exact Computation Project
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _POINT2D_H
|
|
||||||
#define _POINT2D_H
|
|
||||||
|
|
||||||
#ifndef CORE_LEVEL
|
|
||||||
# define CORE_LEVEL 3
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <CGAL/CORE/CORE.h>
|
|
||||||
#include <CGAL/CORE/linearAlgebra.h>
|
|
||||||
#include <CGAL/CORE/geombase.h>
|
|
||||||
|
|
||||||
class Point2d : public GeomObj {
|
|
||||||
|
|
||||||
private:
|
|
||||||
double x, y;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
//CONSTRUCTORS
|
|
||||||
//
|
|
||||||
Point2d(); //initialized to origin(0,0)
|
|
||||||
Point2d(double, double);
|
|
||||||
Point2d(const Point2d &);
|
|
||||||
Point2d(Vector v);
|
|
||||||
//create a point initialized to the point $(v[0], v[1])$
|
|
||||||
//precondition: v.dim() = 2
|
|
||||||
|
|
||||||
//DESTRUCTOR
|
|
||||||
virtual ~Point2d() {}
|
|
||||||
|
|
||||||
//ASSIGNMENT AND QUERY
|
|
||||||
//
|
|
||||||
Point2d& operator=(const Point2d&);
|
|
||||||
|
|
||||||
double X() const { return x; }
|
|
||||||
double Y() const { return y; }
|
|
||||||
void setX( const double a){ x = a; }
|
|
||||||
void setY( const double a){ y = a; }
|
|
||||||
void set( const double a, const double b){ x = a; y = b;}
|
|
||||||
|
|
||||||
int dim() const { return 2; }
|
|
||||||
|
|
||||||
//CONVERSION
|
|
||||||
//
|
|
||||||
Vector toVector() const { return Vector(X(), Y()); }
|
|
||||||
|
|
||||||
//DISTANCES
|
|
||||||
//
|
|
||||||
double distance(const Point2d) const;
|
|
||||||
// returns the Euclidean distance between p and this
|
|
||||||
|
|
||||||
double distance() const { return distance(Point2d(0, 0)); }
|
|
||||||
// returns distance between this and origin
|
|
||||||
|
|
||||||
//VECTOR OPERATIONS
|
|
||||||
//
|
|
||||||
Vector operator-(const Point2d &) const;
|
|
||||||
Point2d operator+(const Vector &) const;
|
|
||||||
|
|
||||||
//TRANSFORMATIONS
|
|
||||||
//
|
|
||||||
Point2d rotate90( const Point2d& q);
|
|
||||||
// returns the point rotated about q by angle of 90 degrees
|
|
||||||
|
|
||||||
//COMPARISONS
|
|
||||||
//
|
|
||||||
bool operator==(const Point2d&) const;
|
|
||||||
bool operator!=(const Point2d& p) const {return !operator==(p); }
|
|
||||||
|
|
||||||
//INPUT-OUTPUT
|
|
||||||
//
|
|
||||||
friend std::ostream& operator<< (std::ostream&, const Point2d);
|
|
||||||
// write point p to output stream
|
|
||||||
// The format is, e.g., Point2d(1.0, 23)
|
|
||||||
|
|
||||||
friend std::istream& operator>> (std::istream&, Point2d&);
|
|
||||||
// reads the x and y coordinates of point p from the input stream
|
|
||||||
// The format is " ( x , y ) " where the white spaces are optional.
|
|
||||||
// Even the comma and the "(" and ")" are optional.
|
|
||||||
// The comment char '#' is allowed, and the rest of
|
|
||||||
// the line is then treated as white space.
|
|
||||||
// However, you must not use other kinds of parenthesis
|
|
||||||
// E.g., the following are all equivalent:
|
|
||||||
// 1.0 -0.2 # comment
|
|
||||||
// ( +1.0, -0.2)
|
|
||||||
// 1.0, -.2
|
|
||||||
|
|
||||||
friend int readPoints(std::istream &iS,
|
|
||||||
Point2d *pA, int MaxN = 1000, int N = 0);
|
|
||||||
// reads a sequence of points from input stream iS into Point2d array pA.
|
|
||||||
// The input stream constains a sequence of 2K+1 numbers of the form
|
|
||||||
// [NN] ( x1 , y1 ) ( x2 , y2 ) ... ( xK , yK )
|
|
||||||
// The i-th point is (xi, yi).
|
|
||||||
// (0) NN is optional if N is given as argument (then N is set to NN)
|
|
||||||
// (1) Any of the "(", "," and ")" are optional
|
|
||||||
// (2) Newlines, extra white spaces, '#' are all ignored.
|
|
||||||
// (3) Also, everything after '#' is discarded.
|
|
||||||
// If N > MaxN, nothing is read and 0 is returned.
|
|
||||||
// Returns the number of points actually read, i.e, min(K, N).
|
|
||||||
|
|
||||||
}; //Point2d Class
|
|
||||||
|
|
||||||
// //////////////////////////////////////////////////
|
|
||||||
// AUXILLIARY FUNCTIONS:
|
|
||||||
// //////////////////////////////////////////////////
|
|
||||||
|
|
||||||
Point2d midPoint(const Point2d& a, const Point2d& b);
|
|
||||||
// returns midpoint between a and b
|
|
||||||
|
|
||||||
Point2d aCenter(const Point2d& a, const Point2d& b, machine_double alpha =0.5);
|
|
||||||
// returns the "asymmetric Center" point
|
|
||||||
// that is alpha-fraction of the distance from a to b
|
|
||||||
|
|
||||||
double area(const Point2d& a, const Point2d& b, const Point2d& c);
|
|
||||||
// returns twice (!) the signed area of triangle (a,b,c)
|
|
||||||
|
|
||||||
int orientation2d(const Point2d& a, const Point2d& b, const Point2d& c);
|
|
||||||
// returns sign of area(a,b,c)
|
|
||||||
|
|
||||||
bool leftTurn(const Point2d& a, const Point2d& b, const Point2d& c);
|
|
||||||
// returns true iff orientation2d(a,b,c) = +1
|
|
||||||
|
|
||||||
bool rightTurn(const Point2d& a, const Point2d& b, const Point2d& c);
|
|
||||||
// returns true iff orientation2d(a,b,c) = -1
|
|
||||||
|
|
||||||
bool collinear(const Point2d& a, const Point2d& b, const Point2d& c);
|
|
||||||
// returns true iff orientation2d(a,b,c) = 0
|
|
||||||
|
|
||||||
bool between(const Point2d& a, const Point2d& b, const Point2d& c);
|
|
||||||
// returns true iff orientation2d(a,b,c) = 0 and b is strictly
|
|
||||||
// between a and c.
|
|
||||||
|
|
||||||
//variant of between:
|
|
||||||
bool betweenVar(const Point2d& a, const Point2d& b, const Point2d& c);
|
|
||||||
// returns true iff the scalar product (a-b, c-b) is positive.
|
|
||||||
// In case orientation2d(a,b,c)=0, then this is equivalent to
|
|
||||||
// b being strictly between a and c.
|
|
||||||
|
|
||||||
// THE FOLLOWING ARE CALLED by
|
|
||||||
// operator>>(..) and readPoints(..)
|
|
||||||
// bool getToNum( std::istream& in, char mark, bool strict=false) ;
|
|
||||||
// bool getToChar( std::istream& in, char mark) ;
|
|
||||||
// bool startNum(char c) ;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,196 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/*****************************************************************
|
|
||||||
* File: segment2d.h
|
|
||||||
* Synopsis:
|
|
||||||
* Basic 2-dimensional geometry
|
|
||||||
* Author: Shubin Zhao (shubinz@cs.nyu.edu), 2001.
|
|
||||||
*
|
|
||||||
*****************************************************************
|
|
||||||
* CORE Library Version 1.4 (July 2001)
|
|
||||||
* Chee Yap <yap@cs.nyu.edu>
|
|
||||||
* Chen Li <chenli@cs.nyu.edu>
|
|
||||||
* Zilin Du <zilin@cs.nyu.edu>
|
|
||||||
*
|
|
||||||
* Copyright (c) 1995, 1996, 1998, 1999, 2000, 2001 Exact Computation Project
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SEGMENT2D_H_
|
|
||||||
#define _SEGMENT2D_H_
|
|
||||||
|
|
||||||
#include <CGAL/CORE/geom2d/point2d.h>
|
|
||||||
#include <CGAL/CORE/geom2d/line2d.h>
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* Class Segment2d:
|
|
||||||
*
|
|
||||||
* An instance s of Segment2d is a finite or infinite line segment
|
|
||||||
* in the two dimensional plane, defined by a start point
|
|
||||||
* s.startPt() and a stop point s.stopPt(). It can be regarded
|
|
||||||
* as an open or a closed segment (default: open), and directed
|
|
||||||
* or not (default: directed).
|
|
||||||
*
|
|
||||||
* We do not necessarily assume that startPt() != stopPt().
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
class Segment2d : public GeomObj {
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
Point2d p0;
|
|
||||||
Point2d p1;
|
|
||||||
bool directed; // segments can be directed or not (default is directed)
|
|
||||||
bool open; // segments can be open or closed (default is open)
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* constructors
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
Segment2d(const Segment2d &);
|
|
||||||
|
|
||||||
Segment2d(const Point2d &p, const Point2d &q);
|
|
||||||
//finite segment with endpoints p and q
|
|
||||||
|
|
||||||
Segment2d(const Point2d & p, const Vector & v);
|
|
||||||
//ray segment
|
|
||||||
|
|
||||||
Segment2d();
|
|
||||||
//unit segment from (0,0) to (1,0)
|
|
||||||
|
|
||||||
virtual ~Segment2d() {}
|
|
||||||
/*************************************************************
|
|
||||||
* member functions
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
Point2d startPt() const { return p0; }
|
|
||||||
Point2d stopPt() const { return p1; }
|
|
||||||
|
|
||||||
void reverse() { Point2d pTmp = p0; p0=p1; p1=pTmp; }
|
|
||||||
// reverses the direction of the segment
|
|
||||||
|
|
||||||
Line2d toLine() const { return Line2d(p0,p1); }
|
|
||||||
|
|
||||||
double length() const { return p0.distance(p1); }
|
|
||||||
//length of segment
|
|
||||||
|
|
||||||
double distance( const Point2d& p ) const;
|
|
||||||
// returns the Euclidean distance between this segment and point q
|
|
||||||
|
|
||||||
Point2d nearPt( const Point2d& p ) const;
|
|
||||||
// returns the point on segment closest to q;
|
|
||||||
|
|
||||||
void setDirected( bool _directed ) { directed = _directed; }
|
|
||||||
void setOpen( bool _open ) { directed = open; }
|
|
||||||
|
|
||||||
// orientation of p0, p1 and p
|
|
||||||
int orientation( const Point2d& p ) const {
|
|
||||||
return toLine().orientation(p); }
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* predicates
|
|
||||||
*************************************************************/
|
|
||||||
bool isOpen() const {return open; }
|
|
||||||
bool isDirected() const {return directed; }
|
|
||||||
bool isTrivial() const {return p0 == p1; }
|
|
||||||
bool isVertical() const { return p0.X() == p1.X(); }
|
|
||||||
bool isHorizontal() const { return p0.Y() == p1.Y(); }
|
|
||||||
bool isCollinear( Point2d& p ) const { return toLine().contains(p); }
|
|
||||||
bool isCoincident( const Segment2d& s) const;
|
|
||||||
bool isParallel( const Segment2d& s ) {
|
|
||||||
return toLine().isParallel( s.toLine() ); }
|
|
||||||
|
|
||||||
bool contains( const Point2d& p ) const;
|
|
||||||
bool contains( const Segment2d& s ) const {
|
|
||||||
return contains(s.startPt()) && contains(s.stopPt()); }
|
|
||||||
|
|
||||||
bool operator==(const Segment2d& s) const { return isCoincident(s); }
|
|
||||||
|
|
||||||
bool operator!=(const Segment2d& s) const { return !isCoincident(s); }
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* intersection
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
int intersects( const Line2d& l ) const;
|
|
||||||
//decides whether *this and t intersect in one point
|
|
||||||
// return dim of intersetion
|
|
||||||
|
|
||||||
int intersects( const Segment2d& s ) const;
|
|
||||||
//decides whether *this and t intersect in one point
|
|
||||||
// return dim of intersetion
|
|
||||||
|
|
||||||
GeomObj* intersection( const Line2d& l ) const;
|
|
||||||
// return intersection point if this segment and l intersect at a single point
|
|
||||||
// the intersection point is returned
|
|
||||||
|
|
||||||
GeomObj* intersection( const Segment2d& s ) const;
|
|
||||||
// return intersection point if this segment and s intersect at a single point
|
|
||||||
// the intersection point is returned
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* angles
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
// the sine/cosine of the angle made with positive x-direction
|
|
||||||
double sine() const { return (p1.Y() - p0.Y()) / length() ; }
|
|
||||||
double cosine() const { return (p1.X() - p0.X()) / length() ; }
|
|
||||||
|
|
||||||
Line2d rotate90(const Point2d& q)
|
|
||||||
{ return Line2d(startPt().rotate90(q), stopPt().rotate90(q)); }
|
|
||||||
|
|
||||||
// computes the orientation (a, b, p), where a!=b and a and b appear
|
|
||||||
// in this order on segment l
|
|
||||||
friend int orientation2d( const Segment2d& s, const Point2d& p) {
|
|
||||||
return orientation2d( s.toLine(), p );
|
|
||||||
}
|
|
||||||
|
|
||||||
friend int cmp_slopes( const Segment2d& s1, const Segment2d& s2)
|
|
||||||
//l1.slope > l2.slope: +1; equal: 0; otherwise: -1
|
|
||||||
{
|
|
||||||
Line2d l1 = s1.toLine();
|
|
||||||
Line2d l2 = s2.toLine();
|
|
||||||
if (l1.slope() == l2.slope())
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return (l1.slope() > l2.slope()) ? +1 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* I/O
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
friend std::istream& operator>>(std::istream& in, Segment2d& l);
|
|
||||||
friend std::ostream &operator<<(std::ostream & out, const Segment2d & l);
|
|
||||||
// syntax: {[} p {===} q {]}
|
|
||||||
|
|
||||||
}; //class Segment2d
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,140 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/*****************************************************************
|
|
||||||
* File: line3d.h
|
|
||||||
* Synopsis:
|
|
||||||
* Basic 3-dimensional geometry
|
|
||||||
* Author: Shubin Zhao (shubinz@cs.nyu.edu), 2001.
|
|
||||||
*
|
|
||||||
*****************************************************************
|
|
||||||
* CORE Library Version 1.4 (July 2001)
|
|
||||||
* Chee Yap <yap@cs.nyu.edu>
|
|
||||||
* Chen Li <chenli@cs.nyu.edu>
|
|
||||||
* Zilin Du <zilin@cs.nyu.edu>
|
|
||||||
*
|
|
||||||
* Copyright (c) 1995, 1996, 1998, 1999, 2000, 2001 Exact Computation Project
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
#ifndef _LINE3D_H_
|
|
||||||
#define _LINE3D_H_
|
|
||||||
|
|
||||||
#include <CGAL/CORE/geom3d/point3d.h>
|
|
||||||
|
|
||||||
class Line3d : public GeomObj{
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* An instance l of the class Line3d is a directed line
|
|
||||||
* in the three dimensional plane. The angle between a right oriented
|
|
||||||
* horizontal line and $l$ is called the direction of $l$.
|
|
||||||
* We assume that l is defined by two points, l.startPt()
|
|
||||||
* and l.stopPt(). We do not assure that these points are distinct.
|
|
||||||
* So the line could be "improper". But most operators assume
|
|
||||||
* that lines are proper (it is the user's responsibility to check).
|
|
||||||
*
|
|
||||||
* In the future, we may generalize this to allow the dual
|
|
||||||
* representation in terms of a linear equation.
|
|
||||||
*
|
|
||||||
* Member Vector is not used in this class. It is intended for use in
|
|
||||||
* the operator+/-, etc.
|
|
||||||
************************************************************/
|
|
||||||
private:
|
|
||||||
|
|
||||||
Point3d p0; // = startPt
|
|
||||||
Point3d p1; // = stopPt
|
|
||||||
Vector V; // = stopPt - startPt
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* constructors
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
Line3d(const Point3d & p, const Vector &v);
|
|
||||||
// line initialized to pass through points p and p+v
|
|
||||||
|
|
||||||
Line3d(const Point3d &p, const Point3d &q);
|
|
||||||
//line is initialized to pass through points p and q directed from p to q
|
|
||||||
|
|
||||||
Line3d(const Line3d &l);
|
|
||||||
//copy constructor
|
|
||||||
|
|
||||||
//Line3d(const Segment3d & s): p0(s.startPt()), p1(s.stopPt()), V(s.direction()) {}
|
|
||||||
//construct from a segment
|
|
||||||
|
|
||||||
Line3d();
|
|
||||||
//horizontal line passes through the origin with direction 0.
|
|
||||||
|
|
||||||
virtual ~Line3d() {}
|
|
||||||
/************************************************************
|
|
||||||
* MEMBERS
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
virtual int dim() const { return 1; }
|
|
||||||
|
|
||||||
Point3d startPt() const { return p0; }
|
|
||||||
Point3d stopPt() const { return p1; }
|
|
||||||
const Vector direction() const { return V; }
|
|
||||||
|
|
||||||
double distance(const Point3d& q) const;
|
|
||||||
// returns the Euclidean distance between this line and point q
|
|
||||||
|
|
||||||
Point3d projection(const Point3d& p) const;
|
|
||||||
// returns the projection of p on this line
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* PREDICATES
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
bool isProper() {return p0 == p1; }
|
|
||||||
bool contains(const Point3d& p) const;
|
|
||||||
|
|
||||||
bool isCoincident(const Line3d& g) const;
|
|
||||||
bool isParallel(const Line3d& g) const; // same slope
|
|
||||||
bool isSkew(const Line3d& l2) const;
|
|
||||||
|
|
||||||
bool operator==(const Line3d& g) const { return isCoincident(g); }
|
|
||||||
bool operator!=(const Line3d& g) { return !operator==(g); }
|
|
||||||
|
|
||||||
int intersects(const Line3d& g ) const;
|
|
||||||
// return the dimension of the intersection of g with this line:
|
|
||||||
// -1 if disjoint (i.e., parallel but distinct lines)
|
|
||||||
// 1 if coincident
|
|
||||||
// 0 if intersect in a point. In this case, the
|
|
||||||
// intersection point is assigned to p if this is available.
|
|
||||||
|
|
||||||
GeomObj* intersection(const Line3d &l) const;
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* I/O
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
friend std::istream& operator>>(std::istream& in, Line3d& l);
|
|
||||||
friend std::ostream& operator<<(std::ostream & out, const Line3d & l);
|
|
||||||
|
|
||||||
}; //class Line3d
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,159 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/*****************************************************************
|
|
||||||
* File: plane3d.h
|
|
||||||
* Synopsis:
|
|
||||||
* Basic 3-dimensional geometry
|
|
||||||
* Author: Shubin Zhao (shubinz@cs.nyu.edu), 2001.
|
|
||||||
*
|
|
||||||
*****************************************************************
|
|
||||||
* CORE Library Version 1.4 (July 2001)
|
|
||||||
* Chee Yap <yap@cs.nyu.edu>
|
|
||||||
* Chen Li <chenli@cs.nyu.edu>
|
|
||||||
* Zilin Du <zilin@cs.nyu.edu>
|
|
||||||
*
|
|
||||||
* Copyright (c) 1995, 1996, 1998, 1999, 2000, 2001 Exact Computation Project
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
#ifndef _PLANE3D_H_
|
|
||||||
#define _PLANE3D_H_
|
|
||||||
|
|
||||||
#include <CGAL/CORE/geom3d/point3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/line3d.h>
|
|
||||||
|
|
||||||
class Segment3d;
|
|
||||||
|
|
||||||
class Plane3d : public GeomObj{
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// ax + by + cz + d = 0
|
|
||||||
double a;
|
|
||||||
double b;
|
|
||||||
double c;
|
|
||||||
double d;
|
|
||||||
Vector n;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/************************************************************
|
|
||||||
* constructors
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
Plane3d(): a(0.0), b(0.0), c(0.0), d(0.0), n(0.0, 0.0, 0.0) {}
|
|
||||||
//trivial plane
|
|
||||||
|
|
||||||
Plane3d(const Plane3d & plane);
|
|
||||||
//copy constructor
|
|
||||||
|
|
||||||
Plane3d(const Point3d & p, const Vector &v);
|
|
||||||
// plane with direction v passes through point p
|
|
||||||
|
|
||||||
Plane3d(const Point3d &p1, const Point3d &p2, const Point3d &p3);
|
|
||||||
//plane passes through points p1, p2, p3
|
|
||||||
|
|
||||||
Plane3d(const Point3d &p, const Line3d &l);
|
|
||||||
//plane passes through point p and line l
|
|
||||||
|
|
||||||
Plane3d(const Point3d &p, const Segment3d &s);
|
|
||||||
//plane passes through point p and segment s
|
|
||||||
|
|
||||||
Plane3d(const Vector &v1, double d1);
|
|
||||||
// plane determined by vector and displacement
|
|
||||||
|
|
||||||
// plane determined by equation
|
|
||||||
Plane3d(double a1, double b1, double c1, double d1);
|
|
||||||
|
|
||||||
virtual ~Plane3d() {}
|
|
||||||
/************************************************************
|
|
||||||
* member functions
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
virtual int dim() const { return 2; }
|
|
||||||
|
|
||||||
double* coeffients() const;
|
|
||||||
double A() const { return a; }
|
|
||||||
double B() const { return b; }
|
|
||||||
double C() const { return c; }
|
|
||||||
double displacement() const { return d; }
|
|
||||||
const Vector& normal() const { return n; }
|
|
||||||
|
|
||||||
// test if plane is trivial
|
|
||||||
bool isTrivial() const { return a==double(0) && b==double(0) && c==double(0); }
|
|
||||||
|
|
||||||
// apply equation of plane to a point
|
|
||||||
double apply( const Point3d& p ) const { return a*p.X()+b*p.Y()+c*p.Z()+d; }
|
|
||||||
|
|
||||||
// plane against plane predicates
|
|
||||||
bool isCoincident(const Plane3d& pl) const;
|
|
||||||
bool isParallel(const Plane3d& pl) const;
|
|
||||||
// test parallel
|
|
||||||
bool isParallel(const Line3d& l) const;
|
|
||||||
|
|
||||||
bool contains( const Point3d& p ) const;
|
|
||||||
bool contains( const Line3d& l ) const;
|
|
||||||
bool contains( const Segment3d& s ) const;
|
|
||||||
|
|
||||||
// returns the projection of p on this line
|
|
||||||
Point3d projection(const Point3d& p) const;
|
|
||||||
|
|
||||||
/** be careful of line(segment) projection
|
|
||||||
* It could be a line(segment) or point
|
|
||||||
* The function returns degenerated line(segment) in point case
|
|
||||||
**/
|
|
||||||
Line3d projection(const Line3d& l) const;
|
|
||||||
Segment3d projection(const Segment3d& s) const;
|
|
||||||
|
|
||||||
//distance
|
|
||||||
double distance( const Point3d& p ) const;
|
|
||||||
double distance( const Line3d& l ) const;
|
|
||||||
double distance( const Segment3d& s ) const;
|
|
||||||
|
|
||||||
/** intersect predicates
|
|
||||||
* later implementation may return like this:
|
|
||||||
* return dimension of intersection
|
|
||||||
* return -1 if not intersect
|
|
||||||
* return 0 if intersect on a point ... and so on.
|
|
||||||
**/
|
|
||||||
int intersects( const Line3d& l ) const;
|
|
||||||
int intersects( const Point3d& p ) const;
|
|
||||||
int intersects( const Segment3d& s ) const;
|
|
||||||
int intersects( const Plane3d& pl ) const;
|
|
||||||
|
|
||||||
// return intersection
|
|
||||||
GeomObj* intersection( const Line3d& l ) const;
|
|
||||||
GeomObj* intersection( const Segment3d& s ) const;
|
|
||||||
GeomObj* intersection( const Plane3d& pl ) const;
|
|
||||||
|
|
||||||
bool operator==(const Plane3d& pl) const { return isCoincident(pl); }
|
|
||||||
bool operator!=(const Plane3d& pl) { return !operator==(pl); }
|
|
||||||
|
|
||||||
friend std::istream& operator>>(std::istream& in, Plane3d& pl);
|
|
||||||
friend std::ostream& operator<<(std::ostream& out, const Plane3d& pl);
|
|
||||||
|
|
||||||
}; //class Plane3d
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,176 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/*****************************************************************
|
|
||||||
* File: point3d.h
|
|
||||||
* Synopsis:
|
|
||||||
* Basic 3-dimensional geometry
|
|
||||||
* Author: Shubin Zhao (shubinz@cs.nyu.edu), 2001.
|
|
||||||
*
|
|
||||||
*****************************************************************
|
|
||||||
* CORE Library Version 1.4 (July 2001)
|
|
||||||
* Chee Yap <yap@cs.nyu.edu>
|
|
||||||
* Chen Li <chenli@cs.nyu.edu>
|
|
||||||
* Zilin Du <zilin@cs.nyu.edu>
|
|
||||||
*
|
|
||||||
* Copyright (c) 1995, 1996, 1998, 1999, 2000, 2001 Exact Computation Project
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
#ifndef _POINT3D_H
|
|
||||||
#define _POINT3D_H
|
|
||||||
|
|
||||||
#include <CGAL/CORE/CORE.h>
|
|
||||||
#include <CGAL/CORE/linearAlgebra.h>
|
|
||||||
#include <CGAL/CORE/geombase.h>
|
|
||||||
|
|
||||||
// class defination for 3d points
|
|
||||||
class Point3d : public GeomObj{
|
|
||||||
|
|
||||||
private:
|
|
||||||
double x, y, z;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* constructors and destructors
|
|
||||||
************************************************************/
|
|
||||||
Point3d(); //initialized to origin(0,0,0)
|
|
||||||
Point3d(double x, double y, double z);
|
|
||||||
Point3d(const Point3d & p);
|
|
||||||
Point3d(const Vector& v);
|
|
||||||
//create a point initialized to the point $(v[0], v[1], v[2])$
|
|
||||||
//precondition: v.dim() >= 3 (only the first 3 components are used)
|
|
||||||
|
|
||||||
//destructor
|
|
||||||
virtual ~Point3d() {}
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* Methods
|
|
||||||
************************************************************/
|
|
||||||
Point3d& operator=(const Point3d&);
|
|
||||||
|
|
||||||
double X() const { return x; }
|
|
||||||
double Y() const { return y; }
|
|
||||||
double Z() const { return z; }
|
|
||||||
|
|
||||||
Vector toVector() const { return Vector(x, y, z); }
|
|
||||||
|
|
||||||
virtual int dim() const { return 0; }
|
|
||||||
|
|
||||||
double distance(const Point3d& p) const;
|
|
||||||
// returns the Euclidean distance between p and this
|
|
||||||
|
|
||||||
double distance() const { return distance(Point3d(0, 0, 0)); }
|
|
||||||
// returns distance between this and origin
|
|
||||||
|
|
||||||
Point3d negate() const { return Point3d(-x, -y, -z); }
|
|
||||||
Vector operator-(const Point3d &p) const;
|
|
||||||
Point3d operator+(const Vector &v) const;
|
|
||||||
Point3d operator-(const Vector &v) const;
|
|
||||||
Point3d operator*(const double& d) const;
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* predicates
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
bool operator==(const Point3d&) const;
|
|
||||||
bool operator!=(const Point3d& p) const {return !operator==(p); }
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* I/O, debugging
|
|
||||||
************************************************************/
|
|
||||||
friend std::ostream& operator<< (std::ostream&, const Point3d&);
|
|
||||||
// write point p to output stream
|
|
||||||
|
|
||||||
friend std::istream& operator>>(std::istream&, Point3d&);
|
|
||||||
// reads the x and y coordinates of point p from the input stream
|
|
||||||
|
|
||||||
// routines to display point:
|
|
||||||
void dump() const {
|
|
||||||
std::cout << "(" << x <<", " << y << z << ")" ; // simply outputs "(x, y)"
|
|
||||||
}
|
|
||||||
|
|
||||||
void dump(const char* s) const {
|
|
||||||
std::cout << s << "(" << x <<", " << y << z << ")" ; // s is the prefix message
|
|
||||||
}
|
|
||||||
|
|
||||||
void dump(const char* s, const char* ss) const {
|
|
||||||
std::cout << s << "(" << x <<", " << y << z << ss ; // ss is the suffix message
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute signed volume of a tetrahedron
|
|
||||||
friend double signed_volume(const Point3d& a, const Point3d& b,
|
|
||||||
const Point3d& c, const Point3d& d);
|
|
||||||
|
|
||||||
};//class Point3d
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* Inline implementation and some 3d predicates
|
|
||||||
************************************************************/
|
|
||||||
// removed inline implementation for compile under visual c++
|
|
||||||
// Zilin Du
|
|
||||||
|
|
||||||
// midPt(p, q) returns (p+q)/2:
|
|
||||||
Point3d midPt3d ( Point3d& a, Point3d& b);
|
|
||||||
|
|
||||||
/* orientation3d(a, b, c, d)
|
|
||||||
* computes the orientation of points a, b, c, d as the sign
|
|
||||||
* of the determinant
|
|
||||||
* | ax ay az 1 |
|
|
||||||
* | bx by bz 1 |
|
|
||||||
* | cx cy cz 1 |
|
|
||||||
* | dx dy dz 1 |
|
|
||||||
* i.e., it returns +1 if d lies in the opposite side w.r.t. the
|
|
||||||
* counter-clockwise side of plane formed by a, b, c
|
|
||||||
*/
|
|
||||||
int orientation3d(const Point3d& a, const Point3d& b,
|
|
||||||
const Point3d& c, const Point3d& d);
|
|
||||||
|
|
||||||
/* area(a, b, c) returns 1/2 times the determinant of orientation(a,b,c)
|
|
||||||
* above. This is the signed area of the triangle determined by a, b, c,
|
|
||||||
* positive if orientation(a,b,c) > 0, and negative otherwise. */
|
|
||||||
|
|
||||||
double volume(const Point3d& a, const Point3d& b,
|
|
||||||
const Point3d& c, const Point3d& d);
|
|
||||||
|
|
||||||
|
|
||||||
/* returns true if points a, b, c and d are coplanar, i.e.,
|
|
||||||
* orientation(a, b, c, d) = 0, and false otherwise.
|
|
||||||
*/
|
|
||||||
bool coplanar(const Point3d& a, const Point3d& b,
|
|
||||||
const Point3d& c, const Point3d& d);
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* CONSTANTS
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
static Point3d ORIGIN_3D(0.0, 0.0, 0.0);
|
|
||||||
static Point3d X_UNIT_3D(1.0, 0.0, 0.0);
|
|
||||||
static Point3d Y_UNIT_3D(0.0, 1.0, 0.0);
|
|
||||||
static Point3d Z_UNIT_3D(0.0, 0.0, 1.0);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,180 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/*****************************************************************
|
|
||||||
* File: polygon3d.h
|
|
||||||
* Synopsis:
|
|
||||||
* Basic 3-dimensional geometry
|
|
||||||
* Author: Shubin Zhao (shubinz@cs.nyu.edu), 2001.
|
|
||||||
*
|
|
||||||
*****************************************************************
|
|
||||||
* CORE Library Version 1.4 (July 2001)
|
|
||||||
* Chee Yap <yap@cs.nyu.edu>
|
|
||||||
* Chen Li <chenli@cs.nyu.edu>
|
|
||||||
* Zilin Du <zilin@cs.nyu.edu>
|
|
||||||
*
|
|
||||||
* Copyright (c) 1995, 1996, 1998, 1999, 2000, 2001 Exact Computation Project
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
#ifndef _POLYGON3D_H_
|
|
||||||
#define _POLYGON3D_H_
|
|
||||||
|
|
||||||
#include <CGAL/CORE/geom3d/point3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/segment3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/plane3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/line3d.h>
|
|
||||||
|
|
||||||
class Polygon3d : public GeomObj {
|
|
||||||
|
|
||||||
private:
|
|
||||||
class PointNode {
|
|
||||||
public:
|
|
||||||
Point3d *p;
|
|
||||||
PointNode *prev;
|
|
||||||
PointNode *next;
|
|
||||||
|
|
||||||
PointNode( const Point3d& _p ) { p = new Point3d(_p); prev=NULL; next=NULL; }
|
|
||||||
~PointNode() { delete p; }
|
|
||||||
};
|
|
||||||
|
|
||||||
PointNode* headN; //head of linked list
|
|
||||||
int size; //length of the list
|
|
||||||
|
|
||||||
public:
|
|
||||||
class Iterator;
|
|
||||||
friend class Iterator;
|
|
||||||
class Iterator {
|
|
||||||
private:
|
|
||||||
PointNode* pointer;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Iterator( PointNode* node ) { pointer = node; }
|
|
||||||
|
|
||||||
PointNode* getPointer() { return pointer; }
|
|
||||||
//bool hasNext() { return pointer->next != Polygon3d::headN; }
|
|
||||||
//Point3d* nextPoint() { pointer=pointer->next; return pointer->prev->p; }
|
|
||||||
|
|
||||||
Iterator& operator =(Iterator & it) { pointer=it.getPointer(); return *this; }
|
|
||||||
|
|
||||||
// postfix only
|
|
||||||
Iterator& operator ++(int) { pointer = pointer->next; return *this; }
|
|
||||||
Iterator& operator --(int) { pointer = pointer->prev; return *this; }
|
|
||||||
Point3d* getPoint() { return pointer->p; }
|
|
||||||
|
|
||||||
// remove current node
|
|
||||||
void remove( ) {
|
|
||||||
PointNode* temp = pointer;
|
|
||||||
pointer->next->prev = pointer->prev;
|
|
||||||
pointer->prev->next = pointer->next;
|
|
||||||
pointer = pointer->prev;
|
|
||||||
delete temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// default
|
|
||||||
Polygon3d();
|
|
||||||
|
|
||||||
// initialize given a triangle
|
|
||||||
// not included, use Polygon3d::toPolygon() instead
|
|
||||||
//Polygon3d(const Triangle3d& T);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//copy constructor
|
|
||||||
Polygon3d(const Polygon3d& plg);
|
|
||||||
|
|
||||||
virtual ~Polygon3d();
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* member functions
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
// view a polygon as a surface
|
|
||||||
virtual int dim() const { return 2; }
|
|
||||||
|
|
||||||
int getSize() const { return size; }
|
|
||||||
|
|
||||||
Iterator getIterator() { return Iterator(headN); }
|
|
||||||
|
|
||||||
bool searchPoint( const Point3d& p ) const;
|
|
||||||
Point3d* getPoint( int index ) const;
|
|
||||||
// append to the end of list
|
|
||||||
void addPoint( const Point3d& p );
|
|
||||||
|
|
||||||
// remove point at given position
|
|
||||||
void removePoint( int index );
|
|
||||||
// return false if point doesn't exist
|
|
||||||
bool removePoint( const Point3d& p );
|
|
||||||
void removeAllPoints();
|
|
||||||
|
|
||||||
// get next point of p
|
|
||||||
// return NULL if p doesn't exist
|
|
||||||
Point3d* nextPoint( const Point3d& p ) const;
|
|
||||||
|
|
||||||
// get previous point of p
|
|
||||||
// return NULL if p doesn't exist
|
|
||||||
Point3d* prevPoint( const Point3d& p ) const;
|
|
||||||
|
|
||||||
//operators
|
|
||||||
Point3d* operator []( int index ) const { return getPoint(index); }
|
|
||||||
Polygon3d& operator =(const Polygon3d& plg);
|
|
||||||
|
|
||||||
// test identity
|
|
||||||
bool operator ==(Polygon3d& plg) const;
|
|
||||||
bool operator !=(Polygon3d& plg) const { return !(*this == plg); }
|
|
||||||
|
|
||||||
// verify if polygon is valid
|
|
||||||
bool verify();
|
|
||||||
|
|
||||||
// test coplanarity
|
|
||||||
bool isCoplanar( const Point3d& p ) const;
|
|
||||||
bool isCoplanar( const Segment3d& s ) const {
|
|
||||||
return isCoplanar(s.startPt()) && isCoplanar(s.stopPt()); }
|
|
||||||
bool isCoplanar( const Line3d& l ) const {
|
|
||||||
return isCoplanar(l.startPt()) && isCoplanar(l.stopPt()); }
|
|
||||||
|
|
||||||
bool isCoplanar( const Plane3d& pl ) const;
|
|
||||||
|
|
||||||
// test if p is on any edge
|
|
||||||
bool isOnEdge( const Point3d& p ) const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void freeMemory(); // delete the point list
|
|
||||||
|
|
||||||
// copy point list from other polygon
|
|
||||||
// make sure old list has been deleted before calling this
|
|
||||||
void copy( const Polygon3d& plg );
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* I/O
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& in, const Polygon3d& plg);
|
|
||||||
|
|
||||||
}; //class Polygon3d
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,177 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/*****************************************************************
|
|
||||||
* File: segment3d.h
|
|
||||||
* Synopsis:
|
|
||||||
* Basic 3-dimensional geometry
|
|
||||||
* Author: Shubin Zhao (shubinz@cs.nyu.edu), 2001.
|
|
||||||
*
|
|
||||||
*****************************************************************
|
|
||||||
* CORE Library Version 1.4 (July 2001)
|
|
||||||
* Chee Yap <yap@cs.nyu.edu>
|
|
||||||
* Chen Li <chenli@cs.nyu.edu>
|
|
||||||
* Zilin Du <zilin@cs.nyu.edu>
|
|
||||||
*
|
|
||||||
* Copyright (c) 1995, 1996, 1998, 1999, 2000, 2001 Exact Computation Project
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
#ifndef _SEGMENT3D_H_
|
|
||||||
#define _SEGMENT3D_H_
|
|
||||||
|
|
||||||
#include <CGAL/CORE/geom3d/point3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/line3d.h>
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* Class Segment3d:
|
|
||||||
*
|
|
||||||
* An instance s of Segment3d is a finite or infinite line segment
|
|
||||||
* in the three dimensional plane, defined by a start point
|
|
||||||
* s.startPt() and a stop point s.stopPt(). It can be regarded
|
|
||||||
* as an open or a closed segment (default: open), and directed
|
|
||||||
* or not (default: directed).
|
|
||||||
*
|
|
||||||
* We do not necessarily assume that startPt() != stopPt().
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
#define S_TYPE_FINITE 0
|
|
||||||
#define S_TYPE_RAY 1
|
|
||||||
#define S_TYPE_LINE 2
|
|
||||||
|
|
||||||
class Plane3d;
|
|
||||||
|
|
||||||
class Segment3d : public GeomObj{
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
Point3d p0;
|
|
||||||
Point3d p1;
|
|
||||||
bool directed; // segments can be directed or not (default is directed)
|
|
||||||
bool open; // segments can be open or closed (default is open)
|
|
||||||
//int finite; // 0=finite, 1=ray, 2=line (default is 0)
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* constructors
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
Segment3d(const Segment3d &s);
|
|
||||||
|
|
||||||
Segment3d(const Point3d &p, const Point3d &q);
|
|
||||||
//finite segment with endpoints p and q
|
|
||||||
|
|
||||||
Segment3d(const Point3d & p, const Vector & v);
|
|
||||||
//ray segment
|
|
||||||
|
|
||||||
Segment3d();
|
|
||||||
//trivial segment from (0,0) to (0,0)
|
|
||||||
|
|
||||||
virtual ~Segment3d() {}
|
|
||||||
/*************************************************************
|
|
||||||
* member functions
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
virtual int dim() const { return 1; }
|
|
||||||
|
|
||||||
Point3d startPt() const { return p0; }
|
|
||||||
Point3d stopPt() const { return p1; }
|
|
||||||
Vector direction() const { return p1 - p0; }
|
|
||||||
|
|
||||||
void reverse();
|
|
||||||
// reverses the direction of the segment
|
|
||||||
|
|
||||||
void setDirected( bool beDirected ) { directed = beDirected; }
|
|
||||||
void setOpen( bool beOpen ) { open = beOpen; }
|
|
||||||
|
|
||||||
void setStartPt( Point3d& p ) { p0 = p; }
|
|
||||||
void setStopPt ( Point3d& p ) { p1 = p; }
|
|
||||||
|
|
||||||
double length() const { return p0.distance(p1); }
|
|
||||||
//length of segment
|
|
||||||
|
|
||||||
Line3d toLine() const { return Line3d(p0,p1); }
|
|
||||||
|
|
||||||
double distance( const Point3d& p ) const;
|
|
||||||
// returns the Euclidean distance between this segment and point q
|
|
||||||
|
|
||||||
Point3d nearPt( const Point3d& q ) const;
|
|
||||||
// returns the point on segment closest to q;
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* predicates
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
bool isDirected() const { return directed; }
|
|
||||||
bool isOpen() const {return open; }
|
|
||||||
bool isTrivial() const {return p0 == p1; }
|
|
||||||
bool isCollinear( const Point3d& p ) const {return toLine().contains(p); }
|
|
||||||
bool contains( const Segment3d& s ) const { return contains(s.startPt()) && contains(s.stopPt()); }
|
|
||||||
bool isCoincident( const Segment3d& s) const;
|
|
||||||
|
|
||||||
bool isCoplanar( const Line3d& s) const;
|
|
||||||
bool isCoplanar( const Segment3d& s) const;
|
|
||||||
|
|
||||||
bool contains( const Point3d& p ) const;
|
|
||||||
|
|
||||||
bool operator==( const Segment3d& s ) { return isCoincident( s ); }
|
|
||||||
|
|
||||||
bool operator!=( const Segment3d& s ) { return !operator==(s); }
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* intersection
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
int intersects( const Line3d& l ) const;
|
|
||||||
//decides whether *this and t intersect in one point
|
|
||||||
// return dim of intersetion
|
|
||||||
|
|
||||||
int intersects( const Segment3d& s ) const;
|
|
||||||
//decides whether *this and t intersect in one point
|
|
||||||
// return dim of intersetion
|
|
||||||
|
|
||||||
GeomObj* intersection( const Line3d& l ) const;
|
|
||||||
// return intersection point if this segment and l intersect at a single point
|
|
||||||
// the intersection point is returned
|
|
||||||
|
|
||||||
GeomObj* intersection( const Segment3d& s ) const;
|
|
||||||
// return intersection point if this segment and s intersect at a single point
|
|
||||||
// the intersection point is returned
|
|
||||||
|
|
||||||
Plane3d bisect_plane() const;
|
|
||||||
// return bisector plane
|
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* I/O
|
|
||||||
*************************************************************/
|
|
||||||
|
|
||||||
friend std::istream& operator>>(std::istream& in, Segment3d& l);
|
|
||||||
friend std::ostream& operator<<(std::ostream& out, const Segment3d& l);
|
|
||||||
|
|
||||||
}; //class Segment3d
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,182 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/*****************************************************************
|
|
||||||
* File: triangle3d.h
|
|
||||||
* Synopsis:
|
|
||||||
* Basic 3-dimensional geometry
|
|
||||||
* Author: Shubin Zhao (shubinz@cs.nyu.edu), 2001.
|
|
||||||
*
|
|
||||||
*****************************************************************
|
|
||||||
* CORE Library Version 1.4 (July 2001)
|
|
||||||
* Chee Yap <yap@cs.nyu.edu>
|
|
||||||
* Chen Li <chenli@cs.nyu.edu>
|
|
||||||
* Zilin Du <zilin@cs.nyu.edu>
|
|
||||||
*
|
|
||||||
* Copyright (c) 1995, 1996, 1998, 1999, 2000, 2001 Exact Computation Project
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _TRIANGLE3D_H_
|
|
||||||
#define _TRIANGLE3D_H_
|
|
||||||
|
|
||||||
#include <CGAL/CORE/geom3d/point3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/line3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/segment3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/plane3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/polygon3d.h>
|
|
||||||
|
|
||||||
class Triangle3d : public GeomObj{
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// three vertices
|
|
||||||
Point3d p0;
|
|
||||||
Point3d p1;
|
|
||||||
Point3d p2;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* constructors
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
Triangle3d(const Point3d& v1, const Point3d& v2, const Point3d& v3);
|
|
||||||
// given three vertices
|
|
||||||
|
|
||||||
Triangle3d(const Triangle3d& T);
|
|
||||||
// given a triangle
|
|
||||||
|
|
||||||
Triangle3d(): p0(ORIGIN_3D), p1(ORIGIN_3D), p2(ORIGIN_3D) {}
|
|
||||||
//trivial triangle
|
|
||||||
|
|
||||||
virtual ~Triangle3d() {}
|
|
||||||
/************************************************************
|
|
||||||
* member functions
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
// view a triangle as a surface
|
|
||||||
virtual int dim() const { return 2; }
|
|
||||||
|
|
||||||
Point3d V1() const { return p0; }
|
|
||||||
Point3d V2() const { return p1; }
|
|
||||||
Point3d V3() const { return p2; }
|
|
||||||
|
|
||||||
Vector normal() const { return (p1 - p0).cross( p2 - p0); }
|
|
||||||
// return normal of the plane containing this triangle
|
|
||||||
|
|
||||||
Plane3d toPlane() const { return Plane3d(p0,p1,p2); }
|
|
||||||
|
|
||||||
Polygon3d* toPolygon() const;
|
|
||||||
/************************************************************
|
|
||||||
* predicates
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
inline bool isCoplanar( const Point3d& p ) const {
|
|
||||||
return orientation3d(p0, p1, p2, p) == 0; }
|
|
||||||
inline bool isCoplanar( const Segment3d& s ) const {
|
|
||||||
return isCoplanar(s.startPt()) && isCoplanar(s.stopPt()); }
|
|
||||||
inline bool isCoplanar( const Line3d& l ) const {
|
|
||||||
return isCoplanar(l.startPt()) && isCoplanar(l.stopPt()); }
|
|
||||||
inline bool isCoplanar( const Triangle3d& T ) const {
|
|
||||||
return isCoplanar(T.V1()) && isCoplanar(T.V2()) && isCoplanar(T.V3()); }
|
|
||||||
inline bool isCoplanar( const Plane3d& pl ) const {
|
|
||||||
return pl.contains(p0) && pl.contains(p1) && pl.contains(p2); }
|
|
||||||
|
|
||||||
// test if p is on triangle
|
|
||||||
bool contains( const Point3d& p ) const;
|
|
||||||
// test if s is on triangle
|
|
||||||
inline bool contains( const Segment3d& s ) const {
|
|
||||||
return contains( s.startPt() ) && contains( s.stopPt() ); }
|
|
||||||
|
|
||||||
// test if T is on triangle
|
|
||||||
inline bool contains( const Triangle3d& T ) const {
|
|
||||||
return contains( T.V1() ) && contains( T.V2() ) && contains( T.V3() ); }
|
|
||||||
|
|
||||||
|
|
||||||
bool isOnEdge( const Point3d& p ) const;
|
|
||||||
// test if p is on the edge
|
|
||||||
|
|
||||||
bool inside( const Point3d& p ) const;
|
|
||||||
// test if p is inside the triangle
|
|
||||||
|
|
||||||
/************************************************************
|
|
||||||
* Intersection
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
/** all intersect predicates return the dimension of the intersection
|
|
||||||
* -1 if disjoint (i.e., parallel but distinct lines)
|
|
||||||
* 0 if coincident
|
|
||||||
* 0 if intersect in a point. In this case, the
|
|
||||||
*
|
|
||||||
// -1 if disjoint (i.e., parallel but distinct lines)
|
|
||||||
// 1 if coincident
|
|
||||||
// 0 if intersect in a point. In this case, the
|
|
||||||
// intersection point is assigned to p if this is available.
|
|
||||||
**/
|
|
||||||
|
|
||||||
// intersect predicates
|
|
||||||
bool do_intersect( const Segment3d& s ) const;
|
|
||||||
bool do_intersect( const Line3d& l ) const;
|
|
||||||
bool do_intersect( const Plane3d& pl ) const;
|
|
||||||
bool do_intersect( const Triangle3d& t ) const;
|
|
||||||
|
|
||||||
// these are consistent with other classes
|
|
||||||
// they return the dimension of the intersection
|
|
||||||
// return -1 if no intersection
|
|
||||||
int intersects( const Segment3d& s ) const;
|
|
||||||
int intersects( const Line3d& l ) const;
|
|
||||||
int intersects( const Plane3d& pl ) const;
|
|
||||||
int intersects( const Triangle3d& T ) const;
|
|
||||||
|
|
||||||
// general intersections
|
|
||||||
GeomObj* intersection( const Segment3d& s ) const;
|
|
||||||
GeomObj* intersection( const Line3d& l ) const;
|
|
||||||
GeomObj* intersection( const Plane3d& pl ) const;
|
|
||||||
GeomObj* intersection( const Triangle3d& t ) const;
|
|
||||||
|
|
||||||
// coplanar intersections
|
|
||||||
GeomObj* coplanar_intersection( const Segment3d& s ) const;
|
|
||||||
GeomObj* coplanar_intersection( const Line3d& l ) const;
|
|
||||||
GeomObj* coplanar_intersection( const Triangle3d& T ) const;
|
|
||||||
|
|
||||||
Polygon3d* in_half_plane( const Point3d& pa,
|
|
||||||
const Point3d& pb,
|
|
||||||
const Point3d& pSide,
|
|
||||||
Polygon3d& plg ) const;
|
|
||||||
|
|
||||||
int coplanar_orientation( const Point3d& pa, const Point3d& pb,
|
|
||||||
const Point3d& ps, const Point3d& p ) const;
|
|
||||||
/************************************************************
|
|
||||||
* I/O
|
|
||||||
************************************************************/
|
|
||||||
|
|
||||||
friend std::istream& operator>>(std::istream& in, Triangle3d& T);
|
|
||||||
friend std::ostream& operator<<(std::ostream & out, const Triangle3d & T);
|
|
||||||
|
|
||||||
}; //class Triangle3d
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/******************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2002 Exact Computation Project
|
|
||||||
*
|
|
||||||
* File: geombase.h
|
|
||||||
* Synopsis:
|
|
||||||
* Code that is common to (and included by) geometry2d.h
|
|
||||||
* and geometry3d.h
|
|
||||||
*
|
|
||||||
* Written by
|
|
||||||
* Shubin Zhao (shubinz@cs.nyu.edu) (2001)
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
#ifndef CORE_GEOMETRY_H
|
|
||||||
#define CORE_GEOMETRY_H
|
|
||||||
|
|
||||||
#include <CGAL/CORE/CORE.h>
|
|
||||||
|
|
||||||
|
|
||||||
//base class for geom2d and geom3d classes
|
|
||||||
class GeomObj {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Exceptions
|
|
||||||
|
|
||||||
class Exception {
|
|
||||||
public:
|
|
||||||
virtual void print_message( char* msg ) { std::cerr << msg <<std::endl; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class NoIntersection : public Exception { };
|
|
||||||
|
|
||||||
class IllegalOperation : public Exception { };
|
|
||||||
|
|
||||||
virtual int dim() const { return -1; }
|
|
||||||
|
|
||||||
}; //class GeomObj
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/******************************************************************
|
|
||||||
* Core Library Version 1.5, August 2002
|
|
||||||
* Copyright (c) 1995-2002 Exact Computation Project
|
|
||||||
*
|
|
||||||
* File: geometry2d.h
|
|
||||||
* Synopsis:
|
|
||||||
* Basic 2-dimensional geometry
|
|
||||||
*
|
|
||||||
* Written by
|
|
||||||
* Yaping Yuan (yqy0522@cs.nyu.edu), 1999.
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
#ifndef CORE_GEOMETRY2D_H
|
|
||||||
#define CORE_GEOMETRY2D_H
|
|
||||||
|
|
||||||
#ifndef CORE_LEVEL
|
|
||||||
# define CORE_LEVEL 3
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <CGAL/CORE/geom2d/point2d.h>
|
|
||||||
#include "CGAL/CORE/geom2d/line2d.h"
|
|
||||||
#include "CGAL/CORE/geom2d/circle2d.h"
|
|
||||||
#include "CGAL/CORE/geom2d/segment2d.h"
|
|
||||||
|
|
||||||
// automaticall link necessary static library under visual c++
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#if CORE_LEVEL == 1
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#pragma comment(lib, "corexDebug_level1.lib")
|
|
||||||
#else
|
|
||||||
#pragma comment(lib, "corex_level1.lib")
|
|
||||||
#endif
|
|
||||||
#elif CORE_LEVEL == 2
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#pragma comment(lib, "corexDebug_level2.lib")
|
|
||||||
#else
|
|
||||||
#pragma comment(lib, "corex_level2.lib")
|
|
||||||
#endif
|
|
||||||
#elif CORE_LEVEL == 3
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#pragma comment(lib, "corexDebug_level3.lib")
|
|
||||||
#else
|
|
||||||
#pragma comment(lib, "corex_level3.lib")
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
* You can redistribute it and/or modify it under the terms of the GNU
|
|
||||||
* Lesser General Public License as published by the Free Software Foundation,
|
|
||||||
* either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Licensees holding a valid commercial license may use this file in
|
|
||||||
* accordance with the commercial license agreement provided with the
|
|
||||||
* software.
|
|
||||||
*
|
|
||||||
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
***************************************************************************/
|
|
||||||
/******************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2002 Exact Computation Project
|
|
||||||
*
|
|
||||||
* File: geometry3d.h
|
|
||||||
*
|
|
||||||
* Written by
|
|
||||||
* Shubin Zhao (shubinz@cs.nyu.edu) (2001)
|
|
||||||
*
|
|
||||||
* WWW URL: http://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*****************************************************************/
|
|
||||||
|
|
||||||
#ifndef CORE_GEOMETRY3D_H
|
|
||||||
#define CORE_GEOMETRY3D_H
|
|
||||||
|
|
||||||
#ifndef CORE_LEVEL
|
|
||||||
# define CORE_LEVEL 3
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <CGAL/CORE/linearAlgebra.h>
|
|
||||||
|
|
||||||
class Point3d;
|
|
||||||
class Line3d;
|
|
||||||
class Segment3d;
|
|
||||||
class Plane3d;
|
|
||||||
class Triangle3d;
|
|
||||||
class Polygon3d;
|
|
||||||
|
|
||||||
#include <CGAL/CORE/geom3d/point3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/line3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/segment3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/plane3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/triangle3d.h>
|
|
||||||
#include <CGAL/CORE/geom3d/polygon3d.h>
|
|
||||||
|
|
||||||
// automaticall link necessary static library under visual c++
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#if CORE_LEVEL == 1
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#pragma comment(lib, "corexDebug_level1.lib")
|
|
||||||
#else
|
|
||||||
#pragma comment(lib, "corex_level1.lib")
|
|
||||||
#endif
|
|
||||||
#elif CORE_LEVEL == 2
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#pragma comment(lib, "corexDebug_level2.lib")
|
|
||||||
#else
|
|
||||||
#pragma comment(lib, "corex_level2.lib")
|
|
||||||
#endif
|
|
||||||
#elif CORE_LEVEL == 3
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#pragma comment(lib, "corexDebug_level3.lib")
|
|
||||||
#else
|
|
||||||
#pragma comment(lib, "corex_level3.lib")
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Loading…
Reference in New Issue