- Main Page
- Modules
- Classes
- Files
- Related Pages

- File List
- File Members

# src/vectorMath/Ray.h

Go to the documentation of this file.

    00001 #ifndef ray_h
    00002 #define ray_h
    00003
    00004 #include "../config.h"
    00005 #include "../typedefs.h"
    00006 #include <iostream>
    00007 #include <ode/ode.h>
    00008 #include "mathex.h"
    00009
    00010 using std::ostream;
    00011 using std::istream;
    00012
    00014 //  Class Line
    00016
    00017 class Ray
    00018 {
    00019     private:
    00020         // Input and output
    00021         ostream &write(ostream &out) const;
    00022
    00023       // Close
    00024
    00025     public:
    00026         Vector3r p; // Any point on the line
    00027         Vector3r v; // Direction of the line
    00028
    00029         // Constructors
    00030         Ray(): p(), v() {}
    00031
    00032         // Line betwen two points OR point and a direction
    00033         Ray(const Vector3r &point1, const Vector3r &point2);
    00034
    00035         // Adjacent points on both lines
    00036         bool adjacentPoints(const Ray &ray, Vector3r &point1, Vector3r &point2) const;
    00037
    00038         // Unary operator
    00039 //      static Ray &invert(const Ray &r, Ray &result) { result.p = r.p; Vector3::invert(r.v, result.v); return result; }
    00040         void invert() { v.invert(); };
    00041
    00042         // Selectors
    00043         Vector3r P() const { return p; }
    00044         Vector3r V() const { return v; }
    00045
    00046         // Distances
    00047         dReal dist(const Ray &ray) const;
    00048         dReal dist(const Vector3r &point) const;
    00049
    00050         // Streaming
    00051         friend ostream &operator<<(ostream &out, const Ray &o) { return o.write(out); }
    00052 };
    00053 #endif