Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-02 09:12:13

0001 // Created on: 1993-03-10
0002 // Created by: JCV
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Geom_Vector_HeaderFile
0018 #define _Geom_Vector_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 
0022 #include <gp_Vec.hxx>
0023 #include <Geom_Geometry.hxx>
0024 #include <Standard_Real.hxx>
0025 
0026 //! The abstract class Vector describes the common
0027 //! behavior of vectors in 3D space.
0028 //! The Geom package provides two concrete classes of
0029 //! vectors: Geom_Direction (unit vector) and Geom_VectorWithMagnitude.
0030 class Geom_Vector : public Geom_Geometry
0031 {
0032 
0033 public:
0034   //! Reverses the vector <me>.
0035   Standard_EXPORT void Reverse();
0036 
0037   //! Returns a copy of <me> reversed.
0038   [[nodiscard]] Standard_EXPORT occ::handle<Geom_Vector> Reversed() const;
0039 
0040   //! Computes the angular value, in radians, between this
0041   //! vector and vector Other. The result is a value between 0 and Pi.
0042   //! Exceptions
0043   //! gp_VectorWithNullMagnitude if:
0044   //! - the magnitude of this vector is less than or equal to
0045   //! gp::Resolution(), or
0046   //! - the magnitude of vector Other is less than or equal
0047   //! to gp::Resolution().
0048   Standard_EXPORT double Angle(const occ::handle<Geom_Vector>& Other) const;
0049 
0050   //! Computes the angular value, in radians, between this
0051   //! vector and vector Other. The result is a value
0052   //! between -Pi and Pi. The vector VRef defines the
0053   //! positive sense of rotation: the angular value is positive
0054   //! if the cross product this ^ Other has the same
0055   //! orientation as VRef (in relation to the plane defined
0056   //! by this vector and vector Other). Otherwise, it is negative.
0057   //! Exceptions
0058   //! Standard_DomainError if this vector, vector Other
0059   //! and vector VRef are coplanar, except if this vector
0060   //! and vector Other are parallel.
0061   //! gp_VectorWithNullMagnitude if the magnitude of
0062   //! this vector, vector Other or vector VRef is less than
0063   //! or equal to gp::Resolution().
0064   Standard_EXPORT double AngleWithRef(const occ::handle<Geom_Vector>& Other,
0065                                       const occ::handle<Geom_Vector>& VRef) const;
0066 
0067   //! Returns the coordinates X, Y and Z of this vector.
0068   Standard_EXPORT void Coord(double& X, double& Y, double& Z) const;
0069 
0070   //! Returns the Magnitude of <me>.
0071   Standard_EXPORT virtual double Magnitude() const = 0;
0072 
0073   //! Returns the square magnitude of <me>.
0074   Standard_EXPORT virtual double SquareMagnitude() const = 0;
0075 
0076   //! Returns the X coordinate of <me>.
0077   Standard_EXPORT double X() const;
0078 
0079   //! Returns the Y coordinate of <me>.
0080   Standard_EXPORT double Y() const;
0081 
0082   //! Returns the Z coordinate of <me>.
0083   Standard_EXPORT double Z() const;
0084 
0085   //! Computes the cross product between <me> and <Other>.
0086   //!
0087   //! Raised if <me> is a "Direction" and if <me> and <Other>
0088   //! are parallel because it is not possible to build a
0089   //! "Direction" with null length.
0090   Standard_EXPORT virtual void Cross(const occ::handle<Geom_Vector>& Other) = 0;
0091 
0092   //! Computes the cross product between <me> and <Other>.
0093   //! A new direction is returned.
0094   //!
0095   //! Raised if <me> is a "Direction" and if the two vectors
0096   //! are parallel because it is not possible to create a
0097   //! "Direction" with null length.
0098   Standard_EXPORT virtual occ::handle<Geom_Vector> Crossed(
0099     const occ::handle<Geom_Vector>& Other) const = 0;
0100 
0101   //! Computes the triple vector product <me> ^(V1 ^ V2).
0102   //!
0103   //! Raised if <me> is a "Direction" and if V1 and V2 are parallel
0104   //! or <me> and (V1 ^ V2) are parallel
0105   Standard_EXPORT virtual void CrossCross(const occ::handle<Geom_Vector>& V1,
0106                                           const occ::handle<Geom_Vector>& V2) = 0;
0107 
0108   //! Computes the triple vector product <me> ^(V1 ^ V2).
0109   //!
0110   //! Raised if <me> is a direction and if V1 and V2 are
0111   //! parallel or <me> and (V1 ^ V2) are parallel
0112   Standard_EXPORT virtual occ::handle<Geom_Vector> CrossCrossed(
0113     const occ::handle<Geom_Vector>& V1,
0114     const occ::handle<Geom_Vector>& V2) const = 0;
0115 
0116   //! Computes the scalar product of this vector and vector Other.
0117   Standard_EXPORT double Dot(const occ::handle<Geom_Vector>& Other) const;
0118 
0119   //! Computes the triple scalar product. Returns me . (V1 ^ V2)
0120   Standard_EXPORT double DotCross(const occ::handle<Geom_Vector>& V1,
0121                                   const occ::handle<Geom_Vector>& V2) const;
0122 
0123   //! Converts this vector into a gp_Vec vector.
0124   Standard_EXPORT const gp_Vec& Vec() const;
0125 
0126   DEFINE_STANDARD_RTTIEXT(Geom_Vector, Geom_Geometry)
0127 
0128 protected:
0129   gp_Vec gpVec;
0130 };
0131 
0132 #endif // _Geom_Vector_HeaderFile