1 // Created on: 2014-10-15
2 // Created by: Denis Bogolepov
3 // Copyright (c) 2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <OpenGl_Sphere.hxx>
18 // =======================================================================
19 // function : OpenGl_Sphere
21 // =======================================================================
22 OpenGl_Sphere::OpenGl_Sphere()
28 // =======================================================================
31 // =======================================================================
32 Standard_Boolean OpenGl_Sphere::Init (const Standard_ShortReal theRadius,
33 const Standard_Integer theNbSlices,
34 const Standard_Integer theNbStacks)
37 return OpenGl_Quadric::init (theNbSlices, theNbStacks);
40 // =======================================================================
41 // function : evalVertex
43 // =======================================================================
44 OpenGl_Vec3 OpenGl_Sphere::evalVertex (const Standard_ShortReal theU,
45 const Standard_ShortReal theV) const
47 const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
48 const Standard_ShortReal aV = static_cast<Standard_ShortReal> (theV * M_PI);
49 return OpenGl_Vec3 (myRadius * cosf (aU) * sinf (aV),
50 -myRadius * sinf (aU) * sinf (aV),
51 myRadius * cosf (aV));
54 // =======================================================================
55 // function : evalNormal
57 // =======================================================================
58 OpenGl_Vec3 OpenGl_Sphere::evalNormal (const Standard_ShortReal theU,
59 const Standard_ShortReal theV) const
61 const Standard_ShortReal aU = static_cast<Standard_ShortReal> (theU * M_PI * 2.0);
62 const Standard_ShortReal aV = static_cast<Standard_ShortReal> (theV * M_PI);
63 return OpenGl_Vec3 (cosf (aU) * sinf (aV),
64 -sinf (aU) * sinf (aV),