Changeset 0e9394 for molecuilder


Ignore:
Timestamp:
Apr 30, 2010, 9:03:57 AM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
7a8319
Parents:
c53e0b
git-author:
Tillmann Crueger <crueger@…> (04/30/10 08:26:28)
git-committer:
Tillmann Crueger <crueger@…> (04/30/10 09:03:57)
Message:

Added a class Space to represent general subspaces of R3 (planes and lines)

Location:
molecuilder/src
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/Makefile.am

    rc53e0b r0e9394  
    123123                 periodentafel.cpp \
    124124                 Plane.cpp \
     125                 Space.cpp \
    125126                 tesselation.cpp \
    126127                 tesselationhelpers.cpp \
     
    161162          periodentafel.hpp \
    162163          Plane.hpp \
     164          Space.hpp \
    163165          stackclass.hpp \
    164166          tesselation.hpp \
  • molecuilder/src/Plane.cpp

    rc53e0b r0e9394  
    88#include "Plane.hpp"
    99#include "vector.hpp"
     10#include "defs.hpp"
    1011#include "Exceptions/LinearDependenceException.hpp"
    1112#include "info.hpp"
     
    1314#include "verbose.hpp"
    1415#include "Helpers/Assert.hpp"
     16#include <cmath>
    1517
    1618/**
     
    163165  return res;
    164166};
     167
     168/************ Methods inherited from Space ****************/
     169
     170double Plane::distance(Vector &point){
     171  double res = point.ScalarProduct(*normalVector)-offset;
     172  return fabs(res);
     173}
     174
     175Vector Plane::getClosestPoint(Vector &point){
     176  Vector difference = distance(point) * (*normalVector);
     177  if(difference.IsZero()){
     178    // the point itself lies on the plane
     179    return point;
     180  }
     181  // get the direction this vector is pointing
     182  double sign = difference.ScalarProduct(*normalVector);
     183  // sign cannot be zero, since normalVector and difference are both != zero
     184  sign = sign/fabs(sign);
     185  return (point - (sign * difference));
     186}
     187
     188bool Plane::isContained(Vector &point){
     189  return (point.ScalarProduct(*normalVector) - offset) < MYEPSILON;
     190}
  • molecuilder/src/Plane.hpp

    rc53e0b r0e9394  
    1111#include <memory>
    1212#include <vector>
     13#include "Space.hpp"
    1314
    1415class Vector;
    1516
    16 class Plane
     17class Plane : public Space
    1718{
    1819  typedef std::auto_ptr<Vector> vec_ptr;
     
    4748  Vector GetIntersection(const Vector &Origin, const Vector &LineVector);
    4849
     50  /****** Methods inherited from Space ***********/
     51
     52  virtual double distance(Vector &point);
     53  virtual Vector getClosestPoint(Vector &point);
     54  virtual bool isContained(Vector &point);
     55
     56
    4957private:
    5058  vec_ptr normalVector;
Note: See TracChangeset for help on using the changeset viewer.