// Filename: lvector3.h // Created by: drose (24Sep99) // //////////////////////////////////////////////////////////////////// #ifndef LVECTOR3_H #define LVECTOR3_H #include #include "coordinateSystem.h" #include "lvecBase3.h" //////////////////////////////////////////////////////////////////// // Class : LVector3 // Description : This is a three-component vector distance (as opposed // to a three-component point, which represents a // particular point in space). Some of the methods are // slightly different between LPoint3 and LVector3; in // particular, subtraction of two points yields a // vector, while addition of a vector and a point yields // a point. //////////////////////////////////////////////////////////////////// template class LVector3 : public LVecBase3 { PUBLISHED: INLINE LVector3(); INLINE LVector3(const LVecBase3 ©); INLINE LVector3 &operator = (const LVecBase3 ©); INLINE LVector3 &operator = (NumType fill_value); INLINE LVector3(NumType fill_value); INLINE LVector3(NumType x, NumType y, NumType z); INLINE static LVector3 zero(); INLINE static LVector3 unit_x(); INLINE static LVector3 unit_y(); INLINE static LVector3 unit_z(); INLINE LVector3 operator - () const; INLINE LVecBase3 operator + (const LVecBase3 &other) const; INLINE LVector3 operator + (const LVector3 &other) const; INLINE LVecBase3 operator - (const LVecBase3 &other) const; INLINE LVector3 operator - (const LVector3 &other) const; INLINE NumType length() const; INLINE NumType length_squared() const; INLINE bool normalize(); INLINE LVector3 cross(const LVecBase3 &other) const; INLINE LVector3 operator * (NumType scalar) const; INLINE LVector3 operator / (NumType scalar) const; // Some special named constructors for LVector3. static LVector3 up(CoordinateSystem cs = CS_default); INLINE static LVector3 right(CoordinateSystem cs = CS_default); static LVector3 forward(CoordinateSystem cs = CS_default); INLINE static LVector3 down(CoordinateSystem cs = CS_default); INLINE static LVector3 left(CoordinateSystem cs = CS_default); INLINE static LVector3 back(CoordinateSystem cs = CS_default); INLINE static LVector3 rfu(NumType right, NumType fwd, NumType up, CoordinateSystem cs = CS_default); public: static TypeHandle get_class_type() { return _type_handle; } static void init_type(); private: static TypeHandle _type_handle; }; // Cast to a different numeric type template INLINE LVector3 lcast_to(NumType2 *type, const LVector3 &source); #include "lvector3.I" EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, LVector3) EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, LVector3) #endif