//=========================================================================== // GoTools Core - SINTEF Geometry Tools Core library, version 2.0.1 // // Copyright (C) 2000-2007, 2010 SINTEF ICT, Applied Mathematics, Norway. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., // 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // Contact information: E-mail: tor.dokken@sintef.no // SINTEF ICT, Department of Applied Mathematics, // P.O. Box 124 Blindern, // 0314 Oslo, Norway. // // Other licenses are also available for this software, notably licenses // for: // - Building commercial software. // - Building software whose source code you wish to keep private. //=========================================================================== 00084 #ifndef _MSC_VER // Getting rid of warning C4996 on Windows 00085 std::copy(v.begin(), v.end(), pstart_); 00086 #else 00087 stdext::unchecked_copy(v.begin(), v.end(), pstart_); 00088 #endif // _MSC_VER 00089 }
Go::Point::Point | ( | RandomAccessIterator | first, | |
RandomAccessIterator | last | |||
) | [inline] |
Constructor making a Point from an iterator range.
Go::Point::Point | ( | double * | begin, | |
double * | end, | |||
bool | own | |||
) | [inline] |
Make a point from an existing range of doubles.
If the own parmeter is false, the Point will refer to the input data, and not own them. If it is true, it will act as a regular point, owning its data.
Definition at line 134 of file Point.h.
00135 : pstart_(0), n_(end-begin), owns_(own) 00136 { 00137 if (owns_) { 00138 pstart_ = new double[n_]; 00139 #ifndef _MSC_VER // Getting rid of warning C4996 on Windows 00140 std::copy(begin, end, pstart_); 00141 #else 00142 stdext::unchecked_copy(begin, end, pstart_); 00143 #endif // _MSC_VER 00144 } else { 00145 pstart_ = begin; 00146 } 00147 }
Go::Point::Point | ( | const Point & | v | ) | [inline] |
Copy constructor.
Definition at line 150 of file Point.h.
References pstart_.
00151 : pstart_(0), n_(v.n_), owns_(true) 00152 { 00153 pstart_ = new double[n_]; 00154 #ifndef _MSC_VER // Getting rid of warning C4996 on Windows 00155 std::copy(v.pstart_, v.pstart_ + n_, pstart_); 00156 #else 00157 stdext::unchecked_copy(v.pstart_, v.pstart_ + n_, pstart_); 00158 #endif // _MSC_VER 00159 }
Go::Point::~Point | ( | ) | [inline] |
double Go::Point::angle | ( | const Point & | v | ) | const [inline] |
The angle between this and another vector. Range is [0.0, M_PI].
Definition at line 477 of file Point.h.
Referenced by Go::CrossTanOffDist::approximationOK(), Go::CrossTangentOffset::approximationOK(), Go::Parabola::directionCone(), Go::Hyperbola::directionCone(), Go::Ellipse::directionCone(), Go::IntCrvEvaluator::evaluate(), Go::Plane::intersect(), main(), Go::Torus::normalCone(), Go::CreatorsUtils::projectCurvePoint(), and Go::surfaceKinks().
00478 { 00479 return acos(cosAngle(v)); 00480 }
double Go::Point::angle_smallest | ( | const Point & | v | ) | const [inline] |
The smallest angle between this and another vector regardless of orientation.
Range is [0.0, 0.5*M_PI].
Definition at line 484 of file Point.h.
References length().
Referenced by Go::extremalPtSurfSurf(), Go::getGnJoints(), Go::CreatorsUtils::projectCurvePoint(), and Go::BoundedUtils::translatePlaneToCurves().
00485 { 00486 double tl1 = length(); 00487 double tl2 = v.length(); 00488 //DEBUG_ERROR_IF(tl1*tl2 == 0.0, "Vector of zero length"); 00489 double tcos = fabs(((*this)*v)/(tl1*tl2)); 00490 tcos = std::min(1.0, tcos); 00491 return acos(tcos); 00492 }
double* Go::Point::begin | ( | ) | [inline] |
const double* Go::Point::begin | ( | ) | const [inline] |
Get a read-only start iterator.
Definition at line 200 of file Point.h.
Referenced by Go::CurveBoundedDomain::closestInDomain(), Go::CurveBoundedDomain::closestOnBoundary(), Go::SplineSurface::closestPoint(), Go::CreatorsUtils::createCrossTangent(), Go::ProjectCurveAndCrossTan::createSeed(), Go::ProjectCurve::createSeed(), Go::CurveOnSurface::ensureParCrvExistence(), Go::SmoothTransition::eval(), Go::TrimCurve::evaluate(), Go::SpaceIntCrv::evaluate(), Go::IntCrvEvaluator::evaluate(), Go::FunctionMinimizer< Functor >::fval(), Go::FunctionMinimizer< Functor >::getPar(), Go::SmoothTransition::getSuggestedSurfaceParameter(), Go::ProjectIntersectionCurve::getSuggestedSurfaceParameter(), Go::HermiteGrid1DMulti::HermiteGrid1DMulti(), Go::AdaptCurve::initSamples(), Go::intersectCurvePoint(), Go::SplineSurface::isDegenerate(), Go::make_trimmed_mesh(), Go::SmoothTransition::offsetIntersectionIterate(), Go::SmoothTransition::offsetIntersectionPoints(), Go::rotateLineCloud(), Go::rotatePoint(), Go::ParamCurve::s1771(), Go::FunctionMinimizer< Functor >::scalarProductSign(), Go::CurveOnSurface::subCurve(), Go::surfaceKinks(), and Go::ParametricSurfaceTesselator::tesselate().
00200 { return pstart_; }
double Go::Point::cosAngle | ( | const Point & | v | ) | const [inline] |
The cosine of the angle between this and another vector.
Definition at line 461 of file Point.h.
References length().
Referenced by Go::SplineSurface::normalCone(), and Go::CreatorsUtils::projectCurvePoint().
00462 { 00463 double tl1 = length(); 00464 double tl2 = v.length(); 00465 //(DEBUG_ERROR_IF(tl1*tl2 == 0.0, "Vector of zero length"); 00466 if (tl1*tl2 == 0.0) 00467 { 00468 //MESSAGE("Vector of zero length in angle compuation"); 00469 return 0.0; 00470 } 00471 double res = ((*this)*v)/(tl1*tl2); 00472 res = std::min(1.0, std::max(-1.0, res)); 00473 return res; 00474 }
The cross product of two vectors.
Throws if dimensions are not 3.
Definition at line 434 of file Point.h.
Referenced by Go::Circle::closestPoint(), Go::closestPtCurveSurf(), Go::Sphere::getLongitudinalCircle(), Go::Torus::getMinorCircle(), Go::make_trimmed_mesh(), Go::Torus::setCoordinateAxes(), Go::Sphere::setCoordinateAxes(), Go::Disc::setCoordinateAxes(), Go::Cylinder::setCoordinateAxes(), Go::Cone::setCoordinateAxes(), Go::Plane::setSpanningVectors(), Go::Parabola::setSpanningVectors(), Go::Hyperbola::setSpanningVectors(), Go::Ellipse::setSpanningVectors(), Go::Circle::setSpanningVectors(), Go::Cylinder::tangentCone(), Go::Cone::tangentCone(), and Go::BoundedUtils::translatePlaneToCurves().
00435 { 00436 return operator%(v); 00437 }
int Go::Point::dimension | ( | ) | const [inline] |
Get the dimension of the Point. Same as size().
Definition at line 210 of file Point.h.
Referenced by Go::DirectionCone::addUnionWith(), Go::BoundingBox::addUnionWith(), Go::BoundingBox::check(), Go::Circle::Circle(), Go::Cone::Cone(), Go::CurveCreators::createCircle(), Go::Cylinder::Cylinder(), Go::Torus::dimension(), Go::Sphere::dimension(), Go::Plane::dimension(), Go::Parabola::dimension(), Go::Line::dimension(), Go::Hyperbola::dimension(), Go::Ellipse::dimension(), Go::Disc::dimension(), Go::Cylinder::dimension(), Go::Cone::dimension(), Go::Circle::dimension(), Go::Ellipse::Ellipse(), Go::CrossTanOffDist::eval(), Go::CrossTangentOffset::eval(), Go::CrossTanOffDist::evalblend(), Go::CrossTanOffDist::evaldiff(), Go::getRotationMatrix(), Go::Hyperbola::Hyperbola(), Go::SweepSurfaceCreator::linearSweptSurface(), Go::operator<(), Go::Parabola::Parabola(), Go::Plane::Plane(), Go::projectCurve(), Go::DirectionCone::read(), Go::BoundingBox::read(), Go::rotateLineCloud(), Go::rotatePoint(), Go::rotateSplineCurve(), Go::rotateSplineSurf(), Go::SweepSurfaceCreator::rotationalSweptSurface(), Go::Parabola::setSpanningVectors(), Go::Hyperbola::setSpanningVectors(), Go::Ellipse::setSpanningVectors(), Go::Circle::setSpanningVectors(), Go::Sphere::Sphere(), Go::SplineCurve::SplineCurve(), Go::Torus::Torus(), Go::translateSplineCurve(), and Go::translateSplineSurf().
00210 { return n_; }
double Go::Point::dist | ( | const Point & | v | ) | const [inline] |
Get the euclidian length of the difference between this vector and another vector.
Definition at line 305 of file Point.h.
Referenced by Go::TrimCurve::approximationOK(), Go::ProjectIntersectionCurve::approximationOK(), Go::ProjectCurve::approximationOK(), Go::LiftCurve::approximationOK(), Go::IntCrvEvaluator::approximationOK(), Go::CrossTanOffDist::approximationOK(), Go::CrossTangentOffset::approximationOK(), Go::ApproxSurf::checkAccuracy(), Go::BoundedSurface::closestBoundaryPoint(), Go::SplineSurface::closestPoint(), Go::BoundedSurface::closestPoint(), Go::closestPtSislCurves(), Go::computeLoopGap(), Go::cornerToCornerSfs(), Go::CurveOnSurface::CurveOnSurface(), Go::SplineCurve::derivCurve(), Go::ParamCurve::estimatedCurveLength(), Go::estimateIsoCurveLength(), Go::estimateSurfaceSize(), Go::CreatorsUtils::fixTrimCurves(), Go::BoundedUtils::intersectWithSurface(), Go::isCoincident(), Go::SplineCurve::isDegenerate(), Go::CurveOnSurface::isDegenerate(), Go::CurveBoundedDomain::isOnCorner(), Go::iterateCornerPos(), main(), Go::orientCurves(), Go::CreatorsUtils::projectCurvePoint(), Go::SmoothTransition::projectPoint(), Go::ParamCurve::s1771(), Go::CurveOnSurface::sameCurve(), Go::CurveOnSurface::sameOrientation(), Go::SplineCurve::SplineCurve(), Go::CurveOnSurface::subCurve(), and Go::surfaceKinks().
00306 { 00307 return sqrt(dist2(v)); 00308 }
double Go::Point::dist2 | ( | const Point & | v | ) | const [inline] |
double Go::Point::distInf | ( | const Point & | v | ) | const [inline] |
double* Go::Point::end | ( | ) | [inline] |
const double* Go::Point::end | ( | ) | const [inline] |
Get a read-only end iterator.
Definition at line 204 of file Point.h.
Referenced by Go::CreatorsUtils::createCrossTangent(), Go::ProjectCurveAndCrossTan::createSeed(), Go::ProjectCurve::createSeed(), Go::CurveOnSurface::ensureParCrvExistence(), Go::SmoothTransition::eval(), Go::SmoothTransition::getSuggestedSurfaceParameter(), Go::ProjectIntersectionCurve::getSuggestedSurfaceParameter(), Go::HermiteGrid1DMulti::HermiteGrid1DMulti(), Go::AdaptCurve::initSamples(), Go::SplineSurface::isDegenerate(), Go::SmoothTransition::offsetIntersectionPoints(), Go::FunctionMinimizer< Functor >::scalarProductSign(), Go::surfaceKinks(), and Go::ParametricSurfaceTesselator::tesselate().
double Go::Point::length | ( | ) | const [inline] |
Get the euclidian length of the vector.
Definition at line 275 of file Point.h.
Referenced by Go::DirectionCone::addUnionWith(), angle_smallest(), Go::SplineSurface::areaDiagonalCross(), Go::SmoothTransition::blend_s1421(), Go::Circle::closestPoint(), Go::closestPtSurfSurfPlaneGeometrical(), Go::SmoothTransition::computeCrosstangentValues(), cosAngle(), Go::CreatorsUtils::createCrossTangent(), Go::CrossTangentOffset::CrossTangentOffset(), Go::CrossTanOffDist::CrossTanOffDist(), Go::DirectionCone::DirectionCone(), Go::ProjectCurveAndCrossTan::eval(), Go::CrossTanOffDist::eval(), Go::CrossTangentOffset::eval(), Go::SpaceIntCrv::evaluate(), Go::getGnJoints(), Go::Parabola::isDegenerate(), Go::Line::isDegenerate(), Go::Hyperbola::isDegenerate(), Go::Ellipse::isDegenerate(), Go::Line::length(), Go::make_trimmed_mesh(), Go::minimalCurvatureRadius(), Go::nextStep(), Go::SplineSurface::normal_not_failsafe(), Go::SplineSurface::normalCone(), Go::SmoothTransition::offsetIntersectionIterate(), Go::SmoothTransition::offsetIntersectionPoints(), Go::SweepSurfaceCreator::rotationalSweptSurface(), Go::Torus::setCoordinateAxes(), Go::Sphere::setCoordinateAxes(), Go::Disc::setCoordinateAxes(), Go::Cylinder::setCoordinateAxes(), Go::Cone::setCoordinateAxes(), Go::DirectionCone::setFromArray(), Go::Plane::setSpanningVectors(), Go::Parabola::setSpanningVectors(), Go::Hyperbola::setSpanningVectors(), Go::Ellipse::setSpanningVectors(), Go::Circle::setSpanningVectors(), and Go::SplineSurface::tangentCone().
00276 { 00277 return sqrt(length2()); 00278 }
double Go::Point::length2 | ( | ) | const [inline] |
Get the square of the euclidian length of the vector.
Definition at line 266 of file Point.h.
Referenced by Go::curvatureRadiusPoints(), and Go::minimise_conjugated_gradient().
double Go::Point::lengthInf | ( | ) | const [inline] |
Get the infinity-norm (or max-norm) length of the vector.
Definition at line 281 of file Point.h.
Referenced by Go::FunctionMinimizer< Functor >::orientDirection().
void Go::Point::normalize | ( | ) | [inline] |
Normalize this vector, i.e.
divide every element by length().
Definition at line 324 of file Point.h.
References DEBUG_ERROR_IF.
Referenced by Go::DirectionCone::addUnionWith(), Go::Circle::Circle(), Go::Line::closestPoint(), Go::SmoothTransition::computeCrosstangentValues(), Go::CurveCreators::createCircle(), Go::CreatorsUtils::createCrossTangent(), Go::Ellipse::Ellipse(), Go::SmoothTransition::eval(), Go::ProjectCurveAndCrossTan::eval(), Go::TrimCurve::evaluate(), Go::SpaceIntCrv::evaluate(), Go::IntCrvEvaluator::evaluate(), Go::extremalPtSurfSurf(), Go::SplineSurface::gridEvaluator(), Go::Hyperbola::Hyperbola(), Go::SplineSurface::mirrorSurface(), Go::SmoothTransition::offsetIntersectionPoints(), Go::Parabola::Parabola(), Go::projectCurve(), Go::Ellipse::read(), Go::Circle::read(), Go::rotateLineCloud(), Go::rotatePoint(), Go::rotateSplineCurve(), Go::rotateSplineSurf(), Go::Torus::setCoordinateAxes(), Go::Sphere::setCoordinateAxes(), Go::Disc::setCoordinateAxes(), Go::Cylinder::setCoordinateAxes(), Go::Cone::setCoordinateAxes(), Go::RotatedBox::setCs(), Go::DirectionCone::setFromArray(), Go::Plane::setSpanningVectors(), Go::Parabola::setSpanningVectors(), Go::Hyperbola::setSpanningVectors(), Go::Ellipse::setSpanningVectors(), and Go::Circle::setSpanningVectors().
00325 { 00326 double tl = length(); 00327 DEBUG_ERROR_IF(tl == 0.0, "Cannot normalize vector of zero length"); 00328 (*this) /= tl; 00329 }
double Go::Point::normalize_checked | ( | ) | [inline] |
The cross product of two vectors.
Dimensions should be 3.
Definition at line 423 of file Point.h.
References DEBUG_ERROR_IF, n_, and pstart_.
double Go::Point::operator* | ( | const Point & | v | ) | const [inline] |
The scalar product (or inner product, or dot product) of two vectors.
Definition at line 411 of file Point.h.
References DEBUG_ERROR_IF, n_, and pstart_.
00412 { 00413 DEBUG_ERROR_IF(n_!=v.n_, 00414 "Dimension mismatch."); 00415 double res = 0; 00416 for (int i = 0; i < n_; ++i) 00417 res += pstart_[i]*v.pstart_[i]; 00418 return res; 00419 }
Point Go::Point::operator* | ( | double | d | ) | const [inline] |
void Go::Point::operator*= | ( | double | d | ) | [inline] |
void Go::Point::operator+= | ( | const Point & | v | ) | [inline] |
Add a vector to this vector.
Definition at line 349 of file Point.h.
References DEBUG_ERROR_IF, n_, and pstart_.
00350 { 00351 DEBUG_ERROR_IF(n_!=v.n_, 00352 "Dimension mismatch."); 00353 for (int i = 0; i < n_; ++i) 00354 pstart_[i] += v.pstart_[i]; 00355 }
Point Go::Point::operator- | ( | ) | const [inline] |
void Go::Point::operator-= | ( | const Point & | v | ) | [inline] |
Subtract a vector from this vector.
Definition at line 365 of file Point.h.
References DEBUG_ERROR_IF, n_, and pstart_.
00366 { 00367 DEBUG_ERROR_IF(n_!=v.n_, 00368 "Dimension mismatch."); 00369 for (int i = 0; i < n_; ++i) 00370 pstart_[i] -= v.pstart_[i]; 00371 }
Point Go::Point::operator/ | ( | double | d | ) | const [inline] |
void Go::Point::operator/= | ( | double | d | ) | [inline] |
double& Go::Point::operator[] | ( | int | i | ) | [inline] |
const double& Go::Point::operator[] | ( | int | i | ) | const [inline] |
void Point::read | ( | std::istream & | is | ) |
Reads a Point elementwise from a standard istream.
The Point must already be initialized with the correct dimension.
Definition at line 22 of file Point.C.
References ALWAYS_ERROR_IF, n_, and pstart_.
Referenced by Go::operator>>().
00024 { 00025 ALWAYS_ERROR_IF (n_ == 0, 00026 "Trying to read into an 0-dimensional (empty) point."); 00027 for (int i = 0; i < n_; ++i) 00028 is >> pstart_[i]; 00029 }
void Go::Point::resetValue | ( | int | idx, | |
double | val | |||
) | [inline] |
Definition at line 257 of file Point.h.
References DEBUG_ERROR_IF.
00258 { 00259 DEBUG_ERROR_IF(idx < 0 || idx >= n_, 00260 "Dimension mismatch."); 00261 pstart_[idx] = val; 00262 }
void Go::Point::resize | ( | int | d | ) | [inline] |
Changing dimension. This loses all info in the point.
Definition at line 213 of file Point.h.
Referenced by Go::ProjectIntersectionCurve::eval(), main(), Go::Torus::read(), Go::Sphere::read(), Go::Plane::read(), Go::Line::read(), Go::Ellipse::read(), Go::Disc::read(), Go::Cylinder::read(), Go::Cone::read(), Go::Circle::read(), Go::BoundedCurve::read(), Go::Parabola::setSpanningVectors(), Go::Hyperbola::setSpanningVectors(), Go::Ellipse::setSpanningVectors(), Go::Circle::setSpanningVectors(), and Go::surfaceKinks().
Set this Point to the cross product of two other Points.
Definition at line 440 of file Point.h.
References DEBUG_ERROR_IF, n_, and pstart_.
00441 { 00442 DEBUG_ERROR_IF(u.n_!=v.n_, 00443 "Dimension mismatch."); 00444 DEBUG_ERROR_IF(u.n_!=3, 00445 "Dimension must be 3."); 00446 00447 bool have_already = owns_ && (n_ >= v.n_); 00448 if (!have_already) { 00449 Point temp(3); 00450 swap(temp); 00451 } else { 00452 n_ = 3; 00453 } 00454 pstart_[0]=u.pstart_[1]*v.pstart_[2] - u.pstart_[2]*v.pstart_[1]; 00455 pstart_[1]=u.pstart_[2]*v.pstart_[0] - u.pstart_[0]*v.pstart_[2]; 00456 pstart_[2]=u.pstart_[0]*v.pstart_[1] - u.pstart_[1]*v.pstart_[0]; 00457 }
void Go::Point::setValue | ( | double | val | ) | [inline] |
void Go::Point::setValue | ( | const double * | array | ) | [inline] |
void Go::Point::setValue | ( | double | x, | |
double | y, | |||
double | z | |||
) | [inline] |
void Go::Point::setValue | ( | double | x, | |
double | y | |||
) | [inline] |
Set function for 2D.
Definition at line 224 of file Point.h.
Referenced by Go::ApproxCurve::checkAccuracy(), Go::AdaptCurve::checkAccuracy(), Go::CrossTangentOffset::CrossTangentOffset(), Go::CrossTanOffDist::CrossTanOffDist(), Go::ProjectCurveAndCrossTan::eval(), Go::SmoothTransition::guessParameterPoints(), Go::HermiteInterpolator::interpolate(), Go::iterateCornerPos(), Go::make_trimmed_mesh(), Go::SmoothTransition::offsetIntersectionPoints(), Go::principalCurvatures(), Go::DirectionCone::setFromArray(), and Go::surfaceKinks().
int Go::Point::size | ( | ) | const [inline] |
Get the dimension of the Point.
Definition at line 208 of file Point.h.
Referenced by Go::CurveBoundedDomain::closestInDomain(), Go::CurveBoundedDomain::closestOnBoundary(), Go::ProjectCurve::eval(), Go::intersectCurvePoint(), main(), Go::SplineSurface::normalCone(), Go::FunctionMinimizer< Functor >::numerical_tolerance(), Go::FunctionMinimizer< Functor >::numPars(), Go::RotatedBox::RotatedBox(), Go::RotatedBox::setFromPoints(), and Go::SplineSurface::tangentCone().
00208 { return n_; }
void Go::Point::swap | ( | Point & | other | ) | [inline] |
void Point::write | ( | std::ostream & | os | ) | const |
Writes a Point elementwise to a standard ostream.
Precision is set to 16 by this function. Dimension is not stored.
Definition at line 33 of file Point.C.
Referenced by Go::operator<<().
int Go::Point::n_ [private] |
Definition at line 39 of file Point.h.
Referenced by operator%(), operator*(), operator+=(), operator-=(), read(), setToCrossProd(), and swap().
bool Go::Point::owns_ [private] |
double* Go::Point::pstart_ [private] |
Definition at line 38 of file Point.h.
Referenced by dist2(), distInf(), operator%(), operator*(), operator+=(), operator-(), operator-=(), Point(), read(), setToCrossProd(), and swap().