0027860: Visualization - clean up Transformation Persistence API
[occt.git] / src / OpenGl / OpenGl_Sphere.cxx
CommitLineData
c827ea3a 1// Created on: 2014-10-15
2// Created by: Denis Bogolepov
3// Copyright (c) 2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#include <OpenGl_Sphere.hxx>
17
18// =======================================================================
19// function : OpenGl_Sphere
20// purpose :
21// =======================================================================
22OpenGl_Sphere::OpenGl_Sphere()
23: myRadius (1.0f)
24{
25 //
26}
27
28// =======================================================================
29// function : Init
30// purpose :
31// =======================================================================
32Standard_Boolean OpenGl_Sphere::Init (const Standard_ShortReal theRadius,
33 const Standard_Integer theNbSlices,
34 const Standard_Integer theNbStacks)
35{
36 myRadius = theRadius;
37 return OpenGl_Quadric::init (theNbSlices, theNbStacks);
38}
39
40// =======================================================================
41// function : evalVertex
42// purpose :
43// =======================================================================
44OpenGl_Vec3 OpenGl_Sphere::evalVertex (const Standard_ShortReal theU,
45 const Standard_ShortReal theV) const
46{
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));
52}
53
54// =======================================================================
55// function : evalNormal
56// purpose :
57// =======================================================================
58OpenGl_Vec3 OpenGl_Sphere::evalNormal (const Standard_ShortReal theU,
59 const Standard_ShortReal theV) const
60{
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),
65 cosf (aV));
66}