IAP GITLAB

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

class Point : public BaseVector<phys::units::length_d>
{
    using Length = phys::units::quantity<phys::units::length_d, double>;
    
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})
    {
    }
    
    auto getCoordinates() const
    {
        return BaseVector<phys::units::length_d>::qVector;
    }
    
    auto getCoordinates(CoordinateSystem const& pCS) const
    {
        if (&pCS == BaseVector<phys::units::length_d>::cs)
        {
            return BaseVector<phys::units::length_d>::qVector;
        }
        else
        {
            return QuantityVector<phys::units::length_d>(CoordinateSystem::getTransformation(*BaseVector<phys::units::length_d>::cs, pCS) * BaseVector<phys::units::length_d>::qVector.eVector);
        }
    }
    
    void rebase(CoordinateSystem const& pCS)
    {
        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
    {        
        return Point(*BaseVector<phys::units::length_d>::cs, getCoordinates() + pVec.getComponents(*BaseVector<phys::units::length_d>::cs));
    }
    
    Vector<phys::units::length_d> operator-(Point const& pB) const
    {
        auto& cs = *BaseVector<phys::units::length_d>::cs;
        return Vector<phys::units::length_d>(cs, getCoordinates() - pB.getCoordinates(cs));
    }