summaryrefslogtreecommitdiff
path: root/basegfx/inc/basegfx/vector/b3dvector.hxx
diff options
context:
space:
mode:
authorArmin Weiss <aw@openoffice.org>2003-11-28 10:18:16 +0000
committerArmin Weiss <aw@openoffice.org>2003-11-28 10:18:16 +0000
commitd539c95155ccc7030411f7494704894a3ac610a8 (patch)
treedc3dbd283a5f501f6e48dd585d80bb158db920e3 /basegfx/inc/basegfx/vector/b3dvector.hxx
parentce0ce72d1fd37f7b8e7cb4ebc372d8cd6b4ab9c0 (diff)
Removed in-between namespaces (curve, matrix, numeric, point, polygon, range, tuple, vector). Names were too common and e.g. vector leaded to problems with some defines. This is now avoided. Also some bug fixes, addition of 3d polygon tooling etc.
Diffstat (limited to 'basegfx/inc/basegfx/vector/b3dvector.hxx')
-rw-r--r--basegfx/inc/basegfx/vector/b3dvector.hxx464
1 files changed, 229 insertions, 235 deletions
diff --git a/basegfx/inc/basegfx/vector/b3dvector.hxx b/basegfx/inc/basegfx/vector/b3dvector.hxx
index 855abb7f71e8..094bacfb50a1 100644
--- a/basegfx/inc/basegfx/vector/b3dvector.hxx
+++ b/basegfx/inc/basegfx/vector/b3dvector.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b3dvector.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: aw $ $Date: 2003-11-26 14:40:05 $
+ * last change: $Author: aw $ $Date: 2003-11-28 11:17:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,270 +68,232 @@
namespace basegfx
{
- namespace matrix
- {
- // predeclaration
- class B3DHomMatrix;
- } // end of namespace matrix;
+ // predeclaration
+ class B3DHomMatrix;
- namespace vector
- {
- /** Base Point class with three double values
+ /** Base Point class with three double values
+
+ This class derives all operators and common handling for
+ a 3D data class from B3DTuple. All necessary extensions
+ which are special for 3D Vectors are added here.
- This class derives all operators and common handling for
- a 3D data class from B3DTuple. All necessary extensions
- which are special for 3D Vectors are added here.
+ @see B3DTuple
+ */
+ class B3DVector : public ::basegfx::B3DTuple
+ {
+ public:
+ /** Create a 3D Vector
- @see B3DTuple
+ @param fVal
+ This parameter is used to initialize the coordinate
+ part of the 3D Vector.
*/
- class B3DVector : public ::basegfx::tuple::B3DTuple
- {
- public:
- /** Create a 3D Vector
-
- @param fVal
- This parameter is used to initialize the coordinate
- part of the 3D Vector.
- */
- B3DVector(double fVal = 0.0)
- : B3DTuple(fVal)
- {}
-
- /** Create a 3D Vector
-
- @param fX
- This parameter is used to initialize the X-coordinate
- of the 3D Vector.
-
- @param fY
- This parameter is used to initialize the Y-coordinate
- of the 3D Vector.
-
- @param fZ
- This parameter is used to initialize the Z-coordinate
- of the 3D Vector.
- */
- B3DVector(double fX, double fY, double fZ)
- : B3DTuple(fX, fY, fZ)
- {}
-
- /** Create a copy of a 3D Vector
-
- @param rVec
- The 3D Vector which will be copied.
- */
- B3DVector(const B3DVector& rVec)
- : B3DTuple(rVec)
- {}
-
- /** constructor with tuple to allow copy-constructing
- from B3DTuple-based classes
- */
- B3DVector(const ::basegfx::tuple::B3DTuple& rTuple)
- : B3DTuple(rTuple)
- {}
-
- ~B3DVector()
- {}
-
- /** *=operator to allow usage from B3DVector, too
- */
- B3DVector& operator*=( const B3DVector& rPnt )
- {
- mfX *= rPnt.mfX;
- mfY *= rPnt.mfY;
- mfZ *= rPnt.mfZ;
- return *this;
- }
+ B3DVector(double fVal = 0.0)
+ : B3DTuple(fVal)
+ {}
- /** *=operator to allow usage from B3DVector, too
- */
- B3DVector& operator*=(double t)
- {
- mfX *= t;
- mfY *= t;
- mfZ *= t;
- return *this;
- }
+ /** Create a 3D Vector
- /** assignment operator to allow assigning the results
- of B3DTuple calculations
- */
- B3DVector& operator=( const ::basegfx::tuple::B3DTuple& rVec )
- {
- mfX = rVec.getX();
- mfY = rVec.getY();
- mfZ = rVec.getZ();
- return *this;
- }
+ @param fX
+ This parameter is used to initialize the X-coordinate
+ of the 3D Vector.
- /** Calculate the length of this 3D Vector
+ @param fY
+ This parameter is used to initialize the Y-coordinate
+ of the 3D Vector.
- @return The Length of the 3D Vector
- */
- double getLength(void) const
- {
- double fLen(scalar(*this));
- if((0.0 == fLen) || (1.0 == fLen))
- return fLen;
- return sqrt(fLen);
- }
+ @param fZ
+ This parameter is used to initialize the Z-coordinate
+ of the 3D Vector.
+ */
+ B3DVector(double fX, double fY, double fZ)
+ : B3DTuple(fX, fY, fZ)
+ {}
- /** Calculate the length in the XY-Plane for this 3D Vector
+ /** Create a copy of a 3D Vector
- @return The XY-Plane Length of the 3D Vector
- */
- double getXYLength(void) const
- {
- double fLen((mfX * mfX) + (mfY * mfY));
- if((0.0 == fLen) || (1.0 == fLen))
- return fLen;
- return sqrt(fLen);
- }
+ @param rVec
+ The 3D Vector which will be copied.
+ */
+ B3DVector(const B3DVector& rVec)
+ : B3DTuple(rVec)
+ {}
- /** Calculate the length in the XZ-Plane for this 3D Vector
+ /** constructor with tuple to allow copy-constructing
+ from B3DTuple-based classes
+ */
+ B3DVector(const ::basegfx::B3DTuple& rTuple)
+ : B3DTuple(rTuple)
+ {}
- @return The XZ-Plane Length of the 3D Vector
- */
- double getXZLength(void) const
- {
- double fLen((mfX * mfZ) + (mfY * mfZ));
- if((0.0 == fLen) || (1.0 == fLen))
- return fLen;
- return sqrt(fLen);
- }
+ ~B3DVector()
+ {}
+
+ /** *=operator to allow usage from B3DVector, too
+ */
+ B3DVector& operator*=( const B3DVector& rPnt )
+ {
+ mfX *= rPnt.mfX;
+ mfY *= rPnt.mfY;
+ mfZ *= rPnt.mfZ;
+ return *this;
+ }
- /** Calculate the length in the YZ-Plane for this 3D Vector
+ /** *=operator to allow usage from B3DVector, too
+ */
+ B3DVector& operator*=(double t)
+ {
+ mfX *= t;
+ mfY *= t;
+ mfZ *= t;
+ return *this;
+ }
- @return The YZ-Plane Length of the 3D Vector
- */
- double getYZLength(void) const
- {
- double fLen((mfY * mfY) + (mfZ * mfZ));
- if((0.0 == fLen) || (1.0 == fLen))
- return fLen;
- return sqrt(fLen);
- }
+ /** assignment operator to allow assigning the results
+ of B3DTuple calculations
+ */
+ B3DVector& operator=( const ::basegfx::B3DTuple& rVec )
+ {
+ mfX = rVec.getX();
+ mfY = rVec.getY();
+ mfZ = rVec.getZ();
+ return *this;
+ }
- /** Set the length of this 3D Vector
+ /** Calculate the length of this 3D Vector
- @param fLen
- The to be achieved length of the 3D Vector
- */
- B3DVector& setLength(double fLen)
- {
- double fLenNow(scalar(*this));
+ @return The Length of the 3D Vector
+ */
+ double getLength(void) const
+ {
+ double fLen(scalar(*this));
+ if((0.0 == fLen) || (1.0 == fLen))
+ return fLen;
+ return sqrt(fLen);
+ }
- if(!::basegfx::numeric::fTools::equalZero(fLenNow))
- {
- const double fOne(1.0);
+ /** Calculate the length in the XY-Plane for this 3D Vector
- if(!::basegfx::numeric::fTools::equal(fOne, fLenNow))
- {
- fLen /= sqrt(fLenNow);
- }
+ @return The XY-Plane Length of the 3D Vector
+ */
+ double getXYLength(void) const
+ {
+ double fLen((mfX * mfX) + (mfY * mfY));
+ if((0.0 == fLen) || (1.0 == fLen))
+ return fLen;
+ return sqrt(fLen);
+ }
- mfX *= fLen;
- mfY *= fLen;
- mfZ *= fLen;
- }
+ /** Calculate the length in the XZ-Plane for this 3D Vector
- return *this;
- }
+ @return The XZ-Plane Length of the 3D Vector
+ */
+ double getXZLength(void) const
+ {
+ double fLen((mfX * mfZ) + (mfY * mfZ));
+ if((0.0 == fLen) || (1.0 == fLen))
+ return fLen;
+ return sqrt(fLen);
+ }
+
+ /** Calculate the length in the YZ-Plane for this 3D Vector
- /** Normalize this 3D Vector
+ @return The YZ-Plane Length of the 3D Vector
+ */
+ double getYZLength(void) const
+ {
+ double fLen((mfY * mfY) + (mfZ * mfZ));
+ if((0.0 == fLen) || (1.0 == fLen))
+ return fLen;
+ return sqrt(fLen);
+ }
- The length of the 3D Vector is set to 1.0
- */
- B3DVector& normalize();
+ /** Set the length of this 3D Vector
- /** Test if this 3D Vector is normalized
+ @param fLen
+ The to be achieved length of the 3D Vector
+ */
+ B3DVector& setLength(double fLen)
+ {
+ double fLenNow(scalar(*this));
- @return
- sal_True if lenth of vector is equal to 1.0
- sal_False else
- */
- sal_Bool isNormalized() const
+ if(!::basegfx::fTools::equalZero(fLenNow))
{
const double fOne(1.0);
- const double fScalar(scalar(*this));
-
- return (::basegfx::numeric::fTools::equal(fOne, fScalar));
- }
- /** get a 3D Vector which is perpendicular to this and a given 3D Vector
+ if(!::basegfx::fTools::equal(fOne, fLenNow))
+ {
+ fLen /= sqrt(fLenNow);
+ }
- @attention This only works if this and the given 3D Vector are
- both normalized.
+ mfX *= fLen;
+ mfY *= fLen;
+ mfZ *= fLen;
+ }
- @param rNormalizedVec
- A normalized 3D Vector.
+ return *this;
+ }
- @return
- A 3D Vector perpendicular to this and the given one
- */
- B3DVector getPerpendicular(const B3DVector& rNormalizedVec) const;
+ /** Normalize this 3D Vector
- /** get the projection of this Vector on the given Plane
+ The length of the 3D Vector is set to 1.0
+ */
+ B3DVector& normalize();
- @attention This only works if the given 3D Vector defining
- the Plane is normalized.
+ /** Test if this 3D Vector is normalized
- @param rNormalizedPlane
- A normalized 3D Vector defining a Plane.
+ @return
+ sal_True if lenth of vector is equal to 1.0
+ sal_False else
+ */
+ sal_Bool isNormalized() const
+ {
+ const double fOne(1.0);
+ const double fScalar(scalar(*this));
- @return
- The projected 3D Vector
- */
- B3DVector getProjectionOnPlane(const B3DVector& rNormalizedPlane) const;
+ return (::basegfx::fTools::equal(fOne, fScalar));
+ }
- /** Calculate the Scalar product
+ /** get a 3D Vector which is perpendicular to this and a given 3D Vector
- This method calculates the Scalar product between this
- and the given 3D Vector.
+ @attention This only works if this and the given 3D Vector are
+ both normalized.
- @param rVec
- A second 3D Vector.
+ @param rNormalizedVec
+ A normalized 3D Vector.
- @return
- The Scalar Product of two 3D Vectors
- */
- double scalar(const B3DVector& rVec) const
- {
- return ((mfX * rVec.mfX) + (mfY * rVec.mfY) + (mfZ * rVec.mfZ));
- }
+ @return
+ A 3D Vector perpendicular to this and the given one
+ */
+ B3DVector getPerpendicular(const B3DVector& rNormalizedVec) const;
- /** Transform vector by given transformation matrix.
+ /** get the projection of this Vector on the given Plane
- Since this is a vector, translational components of the
- matrix are disregarded.
- */
- B3DVector& operator*=( const matrix::B3DHomMatrix& rMat );
+ @attention This only works if the given 3D Vector defining
+ the Plane is normalized.
- static const B3DVector& getEmptyVector()
- {
- return (const B3DVector&) ::basegfx::tuple::B3DTuple::getEmptyTuple();
- }
- };
+ @param rNormalizedPlane
+ A normalized 3D Vector defining a Plane.
- // external operators
- //////////////////////////////////////////////////////////////////////////
+ @return
+ The projected 3D Vector
+ */
+ B3DVector getProjectionOnPlane(const B3DVector& rNormalizedPlane) const;
- /** get a 3D Vector which is in 2D (ignoring
- the Z-Coordinate) perpendicular to a given 3D Vector
+ /** Calculate the Scalar product
- @attention This only works if the given 3D Vector is normalized.
+ This method calculates the Scalar product between this
+ and the given 3D Vector.
- @param rNormalizedVec
- A normalized 3D Vector.
+ @param rVec
+ A second 3D Vector.
@return
- A 3D Vector perpendicular to the given one in X,Y (2D).
+ The Scalar Product of two 3D Vectors
*/
- inline B3DVector getPerpendicular2D( const B3DVector& rNormalizedVec )
+ double scalar(const B3DVector& rVec) const
{
- B3DVector aPerpendicular(-rNormalizedVec.getY(), rNormalizedVec.getX(), rNormalizedVec.getZ());
- return aPerpendicular;
+ return ((mfX * rVec.mfX) + (mfY * rVec.mfY) + (mfZ * rVec.mfZ));
}
/** Transform vector by given transformation matrix.
@@ -339,28 +301,60 @@ namespace basegfx
Since this is a vector, translational components of the
matrix are disregarded.
*/
- B3DVector operator*( const matrix::B3DHomMatrix& rMat, const B3DVector& rVec );
+ B3DVector& operator*=( const B3DHomMatrix& rMat );
- /** Calculate the Cross Product of two 3D Vectors
+ static const B3DVector& getEmptyVector()
+ {
+ return (const B3DVector&) ::basegfx::B3DTuple::getEmptyTuple();
+ }
+ };
- @param rVecA
- A first 3D Vector.
+ // external operators
+ //////////////////////////////////////////////////////////////////////////
- @param rVecB
- A second 3D Vector.
+ /** get a 3D Vector which is in 2D (ignoring
+ the Z-Coordinate) perpendicular to a given 3D Vector
- @return
- The Cross Product of both 3D Vectors
- */
- inline B3DVector cross(const B3DVector& rVecA, const B3DVector& rVecB)
- {
- B3DVector aVec(
- rVecA.getY() * rVecB.getZ() - rVecA.getZ() * rVecB.getY(),
- rVecA.getZ() * rVecB.getX() - rVecA.getX() * rVecB.getZ(),
- rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX());
- return aVec;
- }
- } // end of namespace vector
+ @attention This only works if the given 3D Vector is normalized.
+
+ @param rNormalizedVec
+ A normalized 3D Vector.
+
+ @return
+ A 3D Vector perpendicular to the given one in X,Y (2D).
+ */
+ inline B3DVector getPerpendicular2D( const B3DVector& rNormalizedVec )
+ {
+ B3DVector aPerpendicular(-rNormalizedVec.getY(), rNormalizedVec.getX(), rNormalizedVec.getZ());
+ return aPerpendicular;
+ }
+
+ /** Transform vector by given transformation matrix.
+
+ Since this is a vector, translational components of the
+ matrix are disregarded.
+ */
+ B3DVector operator*( const B3DHomMatrix& rMat, const B3DVector& rVec );
+
+ /** Calculate the Cross Product of two 3D Vectors
+
+ @param rVecA
+ A first 3D Vector.
+
+ @param rVecB
+ A second 3D Vector.
+
+ @return
+ The Cross Product of both 3D Vectors
+ */
+ inline B3DVector cross(const B3DVector& rVecA, const B3DVector& rVecB)
+ {
+ B3DVector aVec(
+ rVecA.getY() * rVecB.getZ() - rVecA.getZ() * rVecB.getY(),
+ rVecA.getZ() * rVecB.getX() - rVecA.getX() * rVecB.getZ(),
+ rVecA.getX() * rVecB.getY() - rVecA.getY() * rVecB.getX());
+ return aVec;
+ }
} // end of namespace basegfx
#endif // _BGFX_VECTOR_B3DVECTOR_HXX