/*******************************************************************************
** Copyright (c) 1992-2026 MAK Technologies, Inc
** All rights reserved.
*******************************************************************************/

#ifndef _4dPoint_H
#define _4dPoint_H

//! \file 4dPoint.h
//! \ingroup matrix
//! \brief This file declares Dt4dPoint.

#include <vlutil/vlMachineTypes.h>
#include <matrix/vlVector.h>


#ifdef DtUSE_UTILITIES_NAMESPACE
namespace DtUSE_UTILITIES_NAMESPACE
{
#endif

class Dt3dPoint;

//! \brief Four-dimensional point, often used with homogeneous coordinates.
//! \ingroup matrix
class DT_DLL_MATRIX Dt4dPoint
{
public:

   //! Default constructor sets all values to zero.
   Dt4dPoint();

   Dt4dPoint(const double& x, const double& y, const double& z, const double& w);
   
   Dt4dPoint(const Dt4dPoint& orig);

   virtual ~Dt4dPoint();

   Dt4dPoint& operator=(const Dt4dPoint& rhs);
 
   //@{
   //! DtTHROW_NEW(DtException, "Invalid index (should be 0..3)");
   const double& operator[](const int i) const;
   double& operator[](const int i);
   //@}

   const double& x() const;
   const double& y() const;
   const double& z() const;
   const double& w() const;

   virtual void set (
      const double& x,
      const double& y,
      const double& z,
      const double& w );

   void setX(const double& x);
   void setY(const double& y);
   void setZ(const double& z);
   void setW(const double& w);

   //! Dt4dPoint( vector.x(), vector.y(), vector.z(), 1) 
   void setFromVector( const DtVector & vector );

   //! Dt4dPoint( point.x(), point.y(), point.z(), 1) 
   void setFrom3dPoint( const Dt3dPoint & point );

   //! Divide every component by w.
   virtual void unhomogenize();

   bool operator==(const Dt4dPoint& rhs) const;
   bool operator!=(const Dt4dPoint& rhs) const;

   Dt4dPoint operator*(const double& rhs) const;
   Dt4dPoint& operator*=(const double& rhs);
    
   Dt4dPoint operator+(const Dt4dPoint& rhs) const;
   Dt4dPoint& operator+=(const Dt4dPoint& rhs);
    
   Dt4dPoint operator-(const Dt4dPoint& rhs) const;
   Dt4dPoint& operator-=(const Dt4dPoint& rhs);

protected:

   double myX;
   double myY;
   double myZ;
   double myW;

};

#define _4dPoint_inl
#include "4dPoint.inl"
#undef _4dPoint_inl
   
#ifdef DtUSE_UTILITIES_NAMESPACE
}
#endif


#endif

