IAP GITLAB

Skip to content
Snippets Groups Projects
Point.h 2.08 KiB
Newer Older
ralfulrich's avatar
ralfulrich committed
#ifndef _include_POINT_H_
#define _include_POINT_H_
#include <fwk/BaseVector.h>
#include <fwk/QuantityVector.h>
#include <fwk/Vector.h>
ralfulrich's avatar
ralfulrich committed
#include <Units/PhysicalUnits.h>
namespace fwk {

  /*!
   * A Point represents a point in position space. It is defined by its
   * coordinates with respect to some CoordinateSystem.
   */
  class Point : public BaseVector<phys::units::length_d>
  {
  public:
  Point(CoordinateSystem const& pCS, QuantityVector<phys::units::length_d> pQVector) :
    BaseVector<phys::units::length_d>(pCS, pQVector)
      {
      }
    
  Point(CoordinateSystem const& cs, Length x, Length y, Length z) :
        BaseVector<phys::units::length_d>(cs, {x, y, z})
    {
    }
    
ralfulrich's avatar
ralfulrich committed
    auto GetCoordinates() const
    {
        return BaseVector<phys::units::length_d>::qVector;
    }
    
ralfulrich's avatar
ralfulrich committed
    auto GetCoordinates(CoordinateSystem const& pCS) const
    {
        if (&pCS == BaseVector<phys::units::length_d>::cs)
        {
            return BaseVector<phys::units::length_d>::qVector;
        }
        else
        {
ralfulrich's avatar
ralfulrich committed
            return QuantityVector<phys::units::length_d>(CoordinateSystem::GetTransformation(*BaseVector<phys::units::length_d>::cs, pCS) * BaseVector<phys::units::length_d>::qVector.eVector);
    /*!
     * transforms the Point into another CoordinateSystem by changing its
     * coordinates interally
     */
    void rebase(CoordinateSystem const& pCS)
    {
ralfulrich's avatar
ralfulrich committed
        BaseVector<phys::units::length_d>::qVector = GetCoordinates(pCS);
        BaseVector<phys::units::length_d>::cs = &pCS;
    }
    
    Point operator+(Vector<phys::units::length_d> const& pVec) const
    {        
ralfulrich's avatar
ralfulrich committed
        return Point(*BaseVector<phys::units::length_d>::cs, GetCoordinates() + pVec.GetComponents(*BaseVector<phys::units::length_d>::cs));
    /*!
     * returns the distance Vector between two points
     */
    Vector<phys::units::length_d> operator-(Point const& pB) const
    {
        auto& cs = *BaseVector<phys::units::length_d>::cs;
ralfulrich's avatar
ralfulrich committed
        return Vector<phys::units::length_d>(cs, GetCoordinates() - pB.GetCoordinates(cs));