1 // Created on: 1993-03-24 2 // Created by: JCV 3 // Copyright (c) 1993-1999 Matra Datavision 4 // Copyright (c) 1999-2014 OPEN CASCADE SAS 5 // 6 // This file is part of Open CASCADE Technology software library. 7 // 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. 13 // 14 // Alternatively, this file may be used under the terms of Open CASCADE 15 // commercial license or contractual agreement. 16 17 #ifndef _Geom2d_Hyperbola_HeaderFile 18 #define _Geom2d_Hyperbola_HeaderFile 19 20 #include <Standard.hxx> 21 #include <Standard_Type.hxx> 22 23 #include <Standard_Real.hxx> 24 #include <Geom2d_Conic.hxx> 25 #include <Standard_Boolean.hxx> 26 #include <Standard_Integer.hxx> 27 class gp_Hypr2d; 28 class gp_Ax2d; 29 class gp_Ax22d; 30 class gp_Pnt2d; 31 class gp_Vec2d; 32 class gp_Trsf2d; 33 class Geom2d_Geometry; 34 35 36 class Geom2d_Hyperbola; 37 DEFINE_STANDARD_HANDLE(Geom2d_Hyperbola, Geom2d_Conic) 38 39 //! Describes a branch of a hyperbola in the plane (2D space). 40 //! A hyperbola is defined by its major and minor radii 41 //! and, as with any conic curve, is positioned in the 42 //! plane with a coordinate system (gp_Ax22d object) where: 43 //! - the origin is the center of the hyperbola, 44 //! - the "X Direction" defines the major axis, and 45 //! - the "Y Direction" defines the minor axis. 46 //! This coordinate system is the local coordinate 47 //! system of the hyperbola. 48 //! The branch of the hyperbola described is the one 49 //! located on the positive side of the major axis. 50 //! The orientation (direct or indirect) of the local 51 //! coordinate system gives an explicit orientation to the 52 //! hyperbola, determining the direction in which the 53 //! parameter increases along the hyperbola. 54 //! The Geom2d_Hyperbola hyperbola is parameterized as follows: 55 //! P(U) = O + MajRad*Cosh(U)*XDir + MinRad*Sinh(U)*YDir 56 //! where: 57 //! - P is the point of parameter U, 58 //! - O, XDir and YDir are respectively the origin, "X 59 //! Direction" and "Y Direction" of its local coordinate system, 60 //! - MajRad and MinRad are the major and minor radii of the hyperbola. 61 //! The "X Axis" of the local coordinate system therefore 62 //! defines the origin of the parameter of the hyperbola. 63 //! The parameter range is ] -infinite,+infinite [. 64 //! The following diagram illustrates the respective 65 //! positions, in the plane of the hyperbola, of the three 66 //! branches of hyperbolas constructed using the 67 //! functions OtherBranch, ConjugateBranch1 and 68 //! ConjugateBranch2: 69 //! ^YAxis 70 //! | 71 //! FirstConjugateBranch 72 //! | 73 //! Other | Main 74 //! --------------------- C 75 //! --------------------->XAxis 76 //! Branch | 77 //! Branch 78 //! | 79 //! SecondConjugateBranch 80 //! | 81 //! Warning 82 //! The value of the major radius (on the major axis) can 83 //! be less than the value of the minor radius (on the minor axis). 84 //! See Also 85 //! GCE2d_MakeHyperbola which provides functions for 86 //! more complex hyperbola constructions 87 //! gp_Ax22d 88 //! gp_Hypr2d for an equivalent, non-parameterized data structure 89 class Geom2d_Hyperbola : public Geom2d_Conic 90 { 91 92 public: 93 94 95 //! Creates an Hyperbola from a non persistent one from package gp 96 Standard_EXPORT Geom2d_Hyperbola(const gp_Hypr2d& H); 97 98 99 //! MajorAxis is the "XAxis" of the hyperbola. 100 //! The YAxis is in the direct sense if "Sense" is True; 101 //! The major radius of the hyperbola is on this "XAxis" and 102 //! the minor radius is on the "YAxis" of the hyperbola. 103 //! Raised if MajorRadius < 0.0 or if MinorRadius < 0.0 104 Standard_EXPORT Geom2d_Hyperbola(const gp_Ax2d& MajorAxis, const Standard_Real MajorRadius, const Standard_Real MinorRadius, const Standard_Boolean Sense = Standard_True); 105 106 107 //! The XDirection of "Axis" is the "XAxis" of the hyperbola and 108 //! the YDirection of "Axis" is the "YAxis". 109 //! The major radius of the hyperbola is on this "XAxis" and 110 //! the minor radius is on the "YAxis" of the hyperbola. 111 //! Raised if MajorRadius < 0.0 or if MinorRadius < 0.0 112 Standard_EXPORT Geom2d_Hyperbola(const gp_Ax22d& Axis, const Standard_Real MajorRadius, const Standard_Real MinorRadius); 113 114 //! Converts the gp_Hypr2d hyperbola H into this hyperbola. 115 Standard_EXPORT void SetHypr2d (const gp_Hypr2d& H); 116 117 //! Assigns a value to the major or minor radius of this hyperbola. 118 //! Exceptions 119 //! Standard_ConstructionError if: 120 //! - MajorRadius is less than 0.0, 121 //! - MinorRadius is less than 0.0. 122 Standard_EXPORT void SetMajorRadius (const Standard_Real MajorRadius); 123 124 //! Assigns a value to the major or minor radius of this hyperbola. 125 //! Exceptions 126 //! Standard_ConstructionError if: 127 //! - MajorRadius is less than 0.0, 128 //! - MinorRadius is less than 0.0. 129 Standard_EXPORT void SetMinorRadius (const Standard_Real MinorRadius); 130 131 //! Converts this hyperbola into a gp_Hypr2d one. 132 Standard_EXPORT gp_Hypr2d Hypr2d() const; 133 134 //! Computes the parameter on the reversed hyperbola, 135 //! for the point of parameter U on this hyperbola. 136 //! For a hyperbola, the returned value is -U. 137 Standard_EXPORT Standard_Real ReversedParameter (const Standard_Real U) const Standard_OVERRIDE; 138 139 //! Returns RealFirst from Standard. 140 Standard_EXPORT Standard_Real FirstParameter() const Standard_OVERRIDE; 141 142 //! returns RealLast from Standard. 143 Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE; 144 145 //! Returns False. 146 Standard_EXPORT Standard_Boolean IsClosed() const Standard_OVERRIDE; 147 148 //! return False for an hyperbola. 149 Standard_EXPORT Standard_Boolean IsPeriodic() const Standard_OVERRIDE; 150 151 152 //! In the local coordinate system of the hyperbola the 153 //! equation of the hyperbola is (X*X)/(A*A) - (Y*Y)/(B*B) = 1.0 154 //! and the equation of the first asymptote is Y = (B/A)*X 155 //! where A is the major radius of the hyperbola and B is the 156 //! minor radius of the hyperbola. 157 //! Raised if MajorRadius = 0.0 158 Standard_EXPORT gp_Ax2d Asymptote1() const; 159 160 161 //! In the local coordinate system of the hyperbola the 162 //! equation of the hyperbola is (X*X)/(A*A) - (Y*Y)/(B*B) = 1.0 163 //! and the equation of the first asymptote is Y = -(B/A)*X. 164 //! where A is the major radius of the hyperbola and B is the 165 //! minor radius of the hyperbola. 166 //! raised if MajorRadius = 0.0 167 Standard_EXPORT gp_Ax2d Asymptote2() const; 168 169 //! Computes the first conjugate branch relative to this hyperbola. 170 //! Note: The diagram given under the class purpose 171 //! indicates where these two branches of hyperbola are 172 //! positioned in relation to this branch of hyperbola. 173 Standard_EXPORT gp_Hypr2d ConjugateBranch1() const; 174 175 //! Computes the second conjugate branch relative to this hyperbola. 176 //! Note: The diagram given under the class purpose 177 //! indicates where these two branches of hyperbola are 178 //! positioned in relation to this branch of hyperbola. 179 Standard_EXPORT gp_Hypr2d ConjugateBranch2() const; 180 181 182 //! This directrix is the line normal to the XAxis of the hyperbola 183 //! in the local plane (Z = 0) at a distance d = MajorRadius / e 184 //! from the center of the hyperbola, where e is the eccentricity of 185 //! the hyperbola. 186 //! This line is parallel to the "YAxis". The intersection point 187 //! between directrix1 and the "XAxis" is the location point of the 188 //! directrix1. This point is on the positive side of the "XAxis". 189 Standard_EXPORT gp_Ax2d Directrix1() const; 190 191 192 //! This line is obtained by the symmetrical transformation 193 //! of "Directrix1" with respect to the "YAxis" of the hyperbola. 194 Standard_EXPORT gp_Ax2d Directrix2() const; 195 196 197 //! Returns the eccentricity of the hyperbola (e > 1). 198 //! If f is the distance between the location of the hyperbola 199 //! and the Focus1 then the eccentricity e = f / MajorRadius. 200 //! raised if MajorRadius = 0.0 201 Standard_EXPORT Standard_Real Eccentricity() const Standard_OVERRIDE; 202 203 204 //! Computes the focal distance. It is the distance between the 205 //! two focus of the hyperbola. 206 Standard_EXPORT Standard_Real Focal() const; 207 208 209 //! Returns the first focus of the hyperbola. This focus is on the 210 //! positive side of the "XAxis" of the hyperbola. 211 Standard_EXPORT gp_Pnt2d Focus1() const; 212 213 214 //! Returns the second focus of the hyperbola. This focus is on the 215 //! negative side of the "XAxis" of the hyperbola. 216 Standard_EXPORT gp_Pnt2d Focus2() const; 217 218 //! Returns the major or minor radius of this hyperbola. 219 //! The major radius is also the distance between the 220 //! center of the hyperbola and the apex of the main 221 //! branch (located on the "X Axis" of the hyperbola). 222 Standard_EXPORT Standard_Real MajorRadius() const; 223 224 //! Returns the major or minor radius of this hyperbola. 225 //! The minor radius is also the distance between the 226 //! center of the hyperbola and the apex of a conjugate 227 //! branch (located on the "Y Axis" of the hyperbola). 228 Standard_EXPORT Standard_Real MinorRadius() const; 229 230 231 //! Computes the "other" branch of this hyperbola. This 232 //! is a symmetrical branch with respect to the center of this hyperbola. 233 //! Note: The diagram given under the class purpose 234 //! indicates where the "other" branch is positioned in 235 //! relation to this branch of the hyperbola. 236 //! ^ YAxis 237 //! | 238 //! FirstConjugateBranch 239 //! | 240 //! Other | Main 241 //! ---------------------------- C 242 //! ------------------------------------------>XAxis 243 //! Branch | Branch 244 //! | 245 //! | 246 //! SecondConjugateBranch 247 //! | 248 //! Warning 249 //! The major radius can be less than the minor radius. 250 Standard_EXPORT gp_Hypr2d OtherBranch() const; 251 252 //! Computes the parameter of this hyperbola. 253 //! The parameter is: 254 //! p = (e*e - 1) * MajorRadius 255 //! where e is the eccentricity of this hyperbola and 256 //! MajorRadius its major radius. 257 //! Exceptions 258 //! Standard_DomainError if the major radius of this 259 //! hyperbola is null. 260 Standard_EXPORT Standard_Real Parameter() const; 261 262 //! Returns in P the point of parameter U. 263 //! P = C + MajorRadius * Cosh (U) * XDir + 264 //! MinorRadius * Sinh (U) * YDir 265 //! where C is the center of the hyperbola , XDir the XDirection and 266 //! YDir the YDirection of the hyperbola's local coordinate system. 267 Standard_EXPORT void D0 (const Standard_Real U, gp_Pnt2d& P) const Standard_OVERRIDE; 268 269 270 //! Returns the point P of parameter U and the first derivative V1. 271 Standard_EXPORT void D1 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1) const Standard_OVERRIDE; 272 273 274 //! Returns the point P of parameter U, the first and second 275 //! derivatives V1 and V2. 276 Standard_EXPORT void D2 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2) const Standard_OVERRIDE; 277 278 279 //! Returns the point P of parameter U, the first second and 280 //! third derivatives V1 V2 and V3. 281 Standard_EXPORT void D3 (const Standard_Real U, gp_Pnt2d& P, gp_Vec2d& V1, gp_Vec2d& V2, gp_Vec2d& V3) const Standard_OVERRIDE; 282 283 //! For the point of parameter U of this hyperbola, 284 //! computes the vector corresponding to the Nth derivative. 285 //! Exceptions Standard_RangeError if N is less than 1. 286 Standard_EXPORT gp_Vec2d DN (const Standard_Real U, const Standard_Integer N) const Standard_OVERRIDE; 287 288 //! Applies the transformation T to this hyperbola. 289 Standard_EXPORT void Transform (const gp_Trsf2d& T) Standard_OVERRIDE; 290 291 //! Creates a new object which is a copy of this hyperbola. 292 Standard_EXPORT Handle(Geom2d_Geometry) Copy() const Standard_OVERRIDE; 293 294 //! Dumps the content of me into the stream 295 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; 296 297 298 299 300 DEFINE_STANDARD_RTTIEXT(Geom2d_Hyperbola,Geom2d_Conic) 301 302 protected: 303 304 305 306 307 private: 308 309 310 Standard_Real majorRadius; 311 Standard_Real minorRadius; 312 313 314 }; 315 316 317 318 319 320 321 322 #endif // _Geom2d_Hyperbola_HeaderFile 323