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>
21 #include <Standard_Type.hxx>
24 #include <Geom_Geometry.hxx>
25 #include <Standard_Real.hxx>
26 class Standard_ConstructionError;
27 class Standard_DomainError;
28 class gp_VectorWithNullMagnitude;
33 DEFINE_STANDARD_HANDLE(Geom_Vector, Geom_Geometry)
35 //! The abstract class Vector describes the common
36 //! behavior of vectors in 3D space.
37 //! The Geom package provides two concrete classes of
38 //! vectors: Geom_Direction (unit vector) and Geom_VectorWithMagnitude.
39 class Geom_Vector : public Geom_Geometry
45 //! Reverses the vector <me>.
46 Standard_EXPORT void Reverse();
49 //! Returns a copy of <me> reversed.
50 Standard_EXPORT Handle(Geom_Vector) Reversed() const;
52 //! Computes the angular value, in radians, between this
53 //! vector and vector Other. The result is a value between 0 and Pi.
55 //! gp_VectorWithNullMagnitude if:
56 //! - the magnitude of this vector is less than or equal to
57 //! gp::Resolution(), or
58 //! - the magnitude of vector Other is less than or equal
59 //! to gp::Resolution().
60 Standard_EXPORT Standard_Real Angle (const Handle(Geom_Vector)& Other) const;
62 //! Computes the angular value, in radians, between this
63 //! vector and vector Other. The result is a value
64 //! between -Pi and Pi. The vector VRef defines the
65 //! positive sense of rotation: the angular value is positive
66 //! if the cross product this ^ Other has the same
67 //! orientation as VRef (in relation to the plane defined
68 //! by this vector and vector Other). Otherwise, it is negative.
70 //! Standard_DomainError if this vector, vector Other
71 //! and vector VRef are coplanar, except if this vector
72 //! and vector Other are parallel.
73 //! gp_VectorWithNullMagnitude if the magnitude of
74 //! this vector, vector Other or vector VRef is less than
75 //! or equal to gp::Resolution().
76 Standard_EXPORT Standard_Real AngleWithRef (const Handle(Geom_Vector)& Other, const Handle(Geom_Vector)& VRef) const;
78 //! Returns the coordinates X, Y and Z of this vector.
79 Standard_EXPORT void Coord (Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const;
81 //! Returns the Magnitude of <me>.
82 Standard_EXPORT virtual Standard_Real Magnitude() const = 0;
84 //! Returns the square magnitude of <me>.
85 Standard_EXPORT virtual Standard_Real SquareMagnitude() const = 0;
87 //! Returns the X coordinate of <me>.
88 Standard_EXPORT Standard_Real X() const;
90 //! Returns the Y coordinate of <me>.
91 Standard_EXPORT Standard_Real Y() const;
93 //! Returns the Z coordinate of <me>.
94 Standard_EXPORT Standard_Real Z() const;
97 //! Computes the cross product between <me> and <Other>.
99 //! Raised if <me> is a "Direction" and if <me> and <Other>
100 //! are parallel because it is not possible to build a
101 //! "Direction" with null length.
102 Standard_EXPORT virtual void Cross (const Handle(Geom_Vector)& Other) = 0;
105 //! Computes the cross product between <me> and <Other>.
106 //! A new direction is returned.
108 //! Raised if <me> is a "Direction" and if the two vectors
109 //! are parallel because it is not possible to create a
110 //! "Direction" with null length.
111 Standard_EXPORT virtual Handle(Geom_Vector) Crossed (const Handle(Geom_Vector)& Other) const = 0;
114 //! Computes the triple vector product <me> ^(V1 ^ V2).
116 //! Raised if <me> is a "Direction" and if V1 and V2 are parallel
117 //! or <me> and (V1 ^ V2) are parallel
118 Standard_EXPORT virtual void CrossCross (const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) = 0;
121 //! Computes the triple vector product <me> ^(V1 ^ V2).
123 //! Raised if <me> is a direction and if V1 and V2 are
124 //! parallel or <me> and (V1 ^ V2) are parallel
125 Standard_EXPORT virtual Handle(Geom_Vector) CrossCrossed (const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) const = 0;
127 //! Computes the scalar product of this vector and vector Other.
128 Standard_EXPORT Standard_Real Dot (const Handle(Geom_Vector)& Other) const;
131 //! Computes the triple scalar product. Returns me . (V1 ^ V2)
132 Standard_EXPORT Standard_Real DotCross (const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) const;
134 //! Converts this vector into a gp_Vec vector.
135 Standard_EXPORT const gp_Vec& Vec() const;
140 DEFINE_STANDARD_RTTIEXT(Geom_Vector,Geom_Geometry)
161 #endif // _Geom_Vector_HeaderFile