summaryrefslogtreecommitdiff
path: root/basegfx/inc/basegfx/vector/b2dvector.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/b2dvector.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/b2dvector.hxx')
-rw-r--r--basegfx/inc/basegfx/vector/b2dvector.hxx382
1 files changed, 188 insertions, 194 deletions
diff --git a/basegfx/inc/basegfx/vector/b2dvector.hxx b/basegfx/inc/basegfx/vector/b2dvector.hxx
index f35c38bb3236..6b5fe724b3e9 100644
--- a/basegfx/inc/basegfx/vector/b2dvector.hxx
+++ b/basegfx/inc/basegfx/vector/b2dvector.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: b2dvector.hxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * 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,250 +68,244 @@
namespace basegfx
{
- namespace matrix
+ // predeclaration
+ class B2DHomMatrix;
+
+ /** Descriptor for the mathematical orientations of two 2D Vectors
+ */
+ enum B2DVectorOrientation
+ {
+ /// mathematically positive oriented
+ ORIENTATION_POSITIVE = 0,
+
+ /// mathematically negative oriented
+ ORIENTATION_NEGATIVE,
+
+ /// mathematically neutral, thus parallel
+ ORIENTATION_NEUTRAL
+ };
+
+ /** Descriptor for the mathematical continuity of two 2D Vectors
+ */
+ enum B2DVectorContinuity
{
- // predeclaration
- class B2DHomMatrix;
- } // end of namespace matrix;
+ /// none
+ CONTINUITY_NONE = 0,
+
+ /// mathematically negative oriented
+ CONTINUITY_C1,
- namespace vector
+ /// mathematically neutral, thus parallel
+ CONTINUITY_C2
+ };
+
+ /** Base Point class with two double values
+
+ This class derives all operators and common handling for
+ a 2D data class from B2DTuple. All necessary extensions
+ which are special for 2D Vectors are added here.
+
+ @see B2DTuple
+ */
+ class B2DVector : public ::basegfx::B2DTuple
{
- /** Descriptor for the mathematical orientations of two 2D Vectors
+ public:
+ /** Create a 2D Vector
+
+ @param fVal
+ This parameter is used to initialize the coordinate
+ part of the 2D Vector.
*/
- enum B2DVectorOrientation
- {
- /// mathematically positive oriented
- ORIENTATION_POSITIVE = 0,
+ B2DVector(double fVal = 0.0)
+ : B2DTuple(fVal)
+ {}
- /// mathematically negative oriented
- ORIENTATION_NEGATIVE,
+ /** Create a 2D Vector
- /// mathematically neutral, thus parallel
- ORIENTATION_NEUTRAL
- };
+ @param fX
+ This parameter is used to initialize the X-coordinate
+ of the 2D Vector.
- /** Descriptor for the mathematical continuity of two 2D Vectors
+ @param fY
+ This parameter is used to initialize the Y-coordinate
+ of the 2D Vector.
*/
- enum B2DVectorContinuity
- {
- /// none
- CONTINUITY_NONE = 0,
+ B2DVector(double fX, double fY)
+ : B2DTuple(fX, fY)
+ {}
- /// mathematically negative oriented
- CONTINUITY_C1,
+ /** Create a copy of a 2D Vector
- /// mathematically neutral, thus parallel
- CONTINUITY_C2
- };
+ @param rVec
+ The 2D Vector which will be copied.
+ */
+ B2DVector(const B2DVector& rVec)
+ : B2DTuple(rVec)
+ {}
- /** Base Point class with two double values
+ /** constructor with tuple to allow copy-constructing
+ from B2DTuple-based classes
+ */
+ B2DVector(const ::basegfx::B2DTuple& rTuple)
+ : B2DTuple(rTuple)
+ {}
- This class derives all operators and common handling for
- a 2D data class from B2DTuple. All necessary extensions
- which are special for 2D Vectors are added here.
+ ~B2DVector()
+ {}
- @see B2DTuple
+ /** *=operator to allow usage from B2DVector, too
*/
- class B2DVector : public ::basegfx::tuple::B2DTuple
+ B2DVector& operator*=( const B2DVector& rPnt )
{
- public:
- /** Create a 2D Vector
-
- @param fVal
- This parameter is used to initialize the coordinate
- part of the 2D Vector.
- */
- B2DVector(double fVal = 0.0)
- : B2DTuple(fVal)
- {}
-
- /** Create a 2D Vector
-
- @param fX
- This parameter is used to initialize the X-coordinate
- of the 2D Vector.
-
- @param fY
- This parameter is used to initialize the Y-coordinate
- of the 2D Vector.
- */
- B2DVector(double fX, double fY)
- : B2DTuple(fX, fY)
- {}
-
- /** Create a copy of a 2D Vector
-
- @param rVec
- The 2D Vector which will be copied.
- */
- B2DVector(const B2DVector& rVec)
- : B2DTuple(rVec)
- {}
-
- /** constructor with tuple to allow copy-constructing
- from B2DTuple-based classes
- */
- B2DVector(const ::basegfx::tuple::B2DTuple& rTuple)
- : B2DTuple(rTuple)
- {}
-
- ~B2DVector()
- {}
-
- /** *=operator to allow usage from B2DVector, too
- */
- B2DVector& operator*=( const B2DVector& rPnt )
- {
- mfX *= rPnt.mfX;
- mfY *= rPnt.mfY;
- return *this;
- }
-
- /** *=operator to allow usage from B2DVector, too
- */
- B2DVector& operator*=(double t)
- {
- mfX *= t;
- mfY *= t;
- return *this;
- }
-
- /** assignment operator to allow assigning the results
- of B2DTuple calculations
- */
- B2DVector& operator=( const ::basegfx::tuple::B2DTuple& rVec );
-
- /** Calculate the length of this 2D Vector
-
- @return The Length of the 2D Vector
- */
- double getLength() const;
-
- /** Set the length of this 2D Vector
-
- @param fLen
- The to be achieved length of the 2D Vector
- */
- B2DVector& setLength(double fLen);
-
- /** Normalize this 2D Vector
-
- The length of the 2D Vector is set to 1.0
- */
- B2DVector& normalize();
-
- /** Test if this 2D Vector is normalized
-
- @return
- sal_True if lenth of vector is equal to 1.0
- sal_False else
- */
- sal_Bool isNormalized() const;
-
- /** Calculate the Scalar with another 2D Vector
-
- @param rVec
- The second 2D Vector
-
- @return
- The Scalar value of the two involved 2D Vectors
- */
- double scalar( const B2DVector& rVec ) const;
-
- /** Calculate the length of the cross product with another 2D Vector
-
- In 2D, returning an actual vector does not make much
- sense here. The magnitude, although, can be readily
- used for tasks such as angle calculations, since for
- the returned value, the following equation holds:
- retVal = getLength(this)*getLength(rVec)*sin(theta),
- with theta being the angle between the two vectors.
+ mfX *= rPnt.mfX;
+ mfY *= rPnt.mfY;
+ return *this;
+ }
- @param rVec
- The second 2D Vector
+ /** *=operator to allow usage from B2DVector, too
+ */
+ B2DVector& operator*=(double t)
+ {
+ mfX *= t;
+ mfY *= t;
+ return *this;
+ }
- @return
- The length of the cross product of the two involved 2D Vectors
- */
- double cross( const B2DVector& rVec ) const;
+ /** assignment operator to allow assigning the results
+ of B2DTuple calculations
+ */
+ B2DVector& operator=( const ::basegfx::B2DTuple& rVec );
- /** Calculate the Angle with another 2D Vector
+ /** Calculate the length of this 2D Vector
- @param rVec
- The second 2D Vector
+ @return The Length of the 2D Vector
+ */
+ double getLength() const;
- @return
- The Angle value of the two involved 2D Vectors in -pi/2 < return < pi/2
- */
- double angle( const B2DVector& rVec ) const;
+ /** Set the length of this 2D Vector
- /** Transform vector by given transformation matrix.
+ @param fLen
+ The to be achieved length of the 2D Vector
+ */
+ B2DVector& setLength(double fLen);
- Since this is a vector, translational components of the
- matrix are disregarded.
- */
- B2DVector& operator*=( const matrix::B2DHomMatrix& rMat );
+ /** Normalize this 2D Vector
- static const B2DVector& getEmptyVector();
- };
+ The length of the 2D Vector is set to 1.0
+ */
+ B2DVector& normalize();
- // external operators
- //////////////////////////////////////////////////////////////////////////
+ /** Test if this 2D Vector is normalized
- /** Calculate the orientation to another 2D Vector
+ @return
+ sal_True if lenth of vector is equal to 1.0
+ sal_False else
+ */
+ sal_Bool isNormalized() const;
- @param rVecA
- The first 2D Vector
+ /** Calculate the Scalar with another 2D Vector
- @param rVecB
+ @param rVec
The second 2D Vector
@return
- The mathematical Orientation of the two involved 2D Vectors
+ The Scalar value of the two involved 2D Vectors
*/
- B2DVectorOrientation getOrientation( const B2DVector& rVecA, const B2DVector& rVecB );
+ double scalar( const B2DVector& rVec ) const;
- /** Calculate a perpendicular 2D Vector to the given one
+ /** Calculate the length of the cross product with another 2D Vector
- @param rVec
- The source 2D Vector
+ In 2D, returning an actual vector does not make much
+ sense here. The magnitude, although, can be readily
+ used for tasks such as angle calculations, since for
+ the returned value, the following equation holds:
+ retVal = getLength(this)*getLength(rVec)*sin(theta),
+ with theta being the angle between the two vectors.
- @attention This only works if the given 2D Vector is normalized.
+ @param rVec
+ The second 2D Vector
@return
- A 2D Vector perpendicular to the one given in parameter rVec
+ The length of the cross product of the two involved 2D Vectors
*/
- B2DVector getPerpendicular( const B2DVector& rNormalizedVec );
-
- /** Test two vectors which need not to be normalized for parallelism
+ double cross( const B2DVector& rVec ) const;
- @param rVecA
- The first 2D Vector
+ /** Calculate the Angle with another 2D Vector
- @param rVecB
+ @param rVec
The second 2D Vector
@return
- sal_Bool if the two values are parallel. Also sal_True if
- one of the vectors is empty.
+ The Angle value of the two involved 2D Vectors in -pi/2 < return < pi/2
*/
- sal_Bool areParallel( const B2DVector& rVecA, const B2DVector& rVecB );
+ double angle( const B2DVector& rVec ) const;
/** Transform vector by given transformation matrix.
Since this is a vector, translational components of the
matrix are disregarded.
*/
- B2DVector operator*( const matrix::B2DHomMatrix& rMat, const B2DVector& rVec );
+ B2DVector& operator*=( const B2DHomMatrix& rMat );
- /** Test continuity between given vectors.
+ static const B2DVector& getEmptyVector();
+ };
- The two given vectors are assumed to describe control points on a
- common point. Calculate if there is a continuity between them.
- */
- ::basegfx::vector::B2DVectorContinuity getContinuity( const B2DVector& rBackVector, const B2DVector& rForwardVector );
+ // external operators
+ //////////////////////////////////////////////////////////////////////////
+
+ /** Calculate the orientation to another 2D Vector
+
+ @param rVecA
+ The first 2D Vector
+
+ @param rVecB
+ The second 2D Vector
+
+ @return
+ The mathematical Orientation of the two involved 2D Vectors
+ */
+ B2DVectorOrientation getOrientation( const B2DVector& rVecA, const B2DVector& rVecB );
+
+ /** Calculate a perpendicular 2D Vector to the given one
+
+ @param rVec
+ The source 2D Vector
+
+ @attention This only works if the given 2D Vector is normalized.
+
+ @return
+ A 2D Vector perpendicular to the one given in parameter rVec
+ */
+ B2DVector getPerpendicular( const B2DVector& rNormalizedVec );
+
+ /** Test two vectors which need not to be normalized for parallelism
+
+ @param rVecA
+ The first 2D Vector
+
+ @param rVecB
+ The second 2D Vector
+
+ @return
+ sal_Bool if the two values are parallel. Also sal_True if
+ one of the vectors is empty.
+ */
+ sal_Bool areParallel( const B2DVector& rVecA, const B2DVector& rVecB );
+
+ /** Transform vector by given transformation matrix.
+
+ Since this is a vector, translational components of the
+ matrix are disregarded.
+ */
+ B2DVector operator*( const B2DHomMatrix& rMat, const B2DVector& rVec );
+
+ /** Test continuity between given vectors.
+
+ The two given vectors are assumed to describe control points on a
+ common point. Calculate if there is a continuity between them.
+ */
+ ::basegfx::B2DVectorContinuity getContinuity( const B2DVector& rBackVector, const B2DVector& rForwardVector );
- } // end of namespace vector
} // end of namespace basegfx
#endif // _BGFX_VECTOR_B2DVECTOR_HXX