1 // Created on: 1993-03-10
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Geom_Vector_HeaderFile
18 #define _Geom_Vector_HeaderFile
20 #include <Standard.hxx>
23 #include <Geom_Geometry.hxx>
24 #include <Standard_Real.hxx>
28 DEFINE_STANDARD_HANDLE(Geom_Vector, Geom_Geometry)
30 //! The abstract class Vector describes the common
31 //! behavior of vectors in 3D space.
32 //! The Geom package provides two concrete classes of
33 //! vectors: Geom_Direction (unit vector) and Geom_VectorWithMagnitude.
34 class Geom_Vector : public Geom_Geometry
40 //! Reverses the vector <me>.
41 Standard_EXPORT void Reverse();
44 //! Returns a copy of <me> reversed.
45 Standard_NODISCARD Standard_EXPORT Handle(Geom_Vector) Reversed() const;
47 //! Computes the angular value, in radians, between this
48 //! vector and vector Other. The result is a value between 0 and Pi.
50 //! gp_VectorWithNullMagnitude if:
51 //! - the magnitude of this vector is less than or equal to
52 //! gp::Resolution(), or
53 //! - the magnitude of vector Other is less than or equal
54 //! to gp::Resolution().
55 Standard_EXPORT Standard_Real Angle (const Handle(Geom_Vector)& Other) const;
57 //! Computes the angular value, in radians, between this
58 //! vector and vector Other. The result is a value
59 //! between -Pi and Pi. The vector VRef defines the
60 //! positive sense of rotation: the angular value is positive
61 //! if the cross product this ^ Other has the same
62 //! orientation as VRef (in relation to the plane defined
63 //! by this vector and vector Other). Otherwise, it is negative.
65 //! Standard_DomainError if this vector, vector Other
66 //! and vector VRef are coplanar, except if this vector
67 //! and vector Other are parallel.
68 //! gp_VectorWithNullMagnitude if the magnitude of
69 //! this vector, vector Other or vector VRef is less than
70 //! or equal to gp::Resolution().
71 Standard_EXPORT Standard_Real AngleWithRef (const Handle(Geom_Vector)& Other, const Handle(Geom_Vector)& VRef) const;
73 //! Returns the coordinates X, Y and Z of this vector.
74 Standard_EXPORT void Coord (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const;
76 //! Returns the Magnitude of <me>.
77 Standard_EXPORT virtual Standard_Real Magnitude() const = 0;
79 //! Returns the square magnitude of <me>.
80 Standard_EXPORT virtual Standard_Real SquareMagnitude() const = 0;
82 //! Returns the X coordinate of <me>.
83 Standard_EXPORT Standard_Real X() const;
85 //! Returns the Y coordinate of <me>.
86 Standard_EXPORT Standard_Real Y() const;
88 //! Returns the Z coordinate of <me>.
89 Standard_EXPORT Standard_Real Z() const;
92 //! Computes the cross product between <me> and <Other>.
94 //! Raised if <me> is a "Direction" and if <me> and <Other>
95 //! are parallel because it is not possible to build a
96 //! "Direction" with null length.
97 Standard_EXPORT virtual void Cross (const Handle(Geom_Vector)& Other) = 0;
100 //! Computes the cross product between <me> and <Other>.
101 //! A new direction is returned.
103 //! Raised if <me> is a "Direction" and if the two vectors
104 //! are parallel because it is not possible to create a
105 //! "Direction" with null length.
106 Standard_EXPORT virtual Handle(Geom_Vector) Crossed (const Handle(Geom_Vector)& Other) const = 0;
109 //! Computes the triple vector product <me> ^(V1 ^ V2).
111 //! Raised if <me> is a "Direction" and if V1 and V2 are parallel
112 //! or <me> and (V1 ^ V2) are parallel
113 Standard_EXPORT virtual void CrossCross (const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) = 0;
116 //! Computes the triple vector product <me> ^(V1 ^ V2).
118 //! Raised if <me> is a direction and if V1 and V2 are
119 //! parallel or <me> and (V1 ^ V2) are parallel
120 Standard_EXPORT virtual Handle(Geom_Vector) CrossCrossed (const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) const = 0;
122 //! Computes the scalar product of this vector and vector Other.
123 Standard_EXPORT Standard_Real Dot (const Handle(Geom_Vector)& Other) const;
126 //! Computes the triple scalar product. Returns me . (V1 ^ V2)
127 Standard_EXPORT Standard_Real DotCross (const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) const;
129 //! Converts this vector into a gp_Vec vector.
130 Standard_EXPORT const gp_Vec& Vec() const;
135 DEFINE_STANDARD_RTTIEXT(Geom_Vector,Geom_Geometry)
156 #endif // _Geom_Vector_HeaderFile