opennurbs_sphere.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(ON_SPHERE_INC_)
18 #define ON_SPHERE_INC_
19 
20 class ON_RevSurface;
21 
22 class ON_CLASS ON_Sphere
23 {
24 public:
25 
26  ON_Plane plane; // equitorial plane
27  double radius; // > 0
28 
29  ON_Sphere();
30  ON_Sphere( const ON_3dPoint& center, double radius ); // center, radius
31  ~ON_Sphere();
32 
33  bool IsValid() const;
34 
35  bool Create( const ON_3dPoint& center, double radius); // center radius
36 
37  ON_Circle LatitudeRadians(double latitude_radians ) const;
38  ON_Circle LatitudeDegrees(double latitude_degrees) const;
39  ON_Circle LongitudeRadians(double longitude_radians) const;
40  ON_Circle LongitudeDegrees(double longitude_degrees) const;
41 
42  ON_3dPoint Center() const;
43  ON_3dPoint NorthPole() const;
44  ON_3dPoint SouthPole() const;
45  double Diameter() const;
46  double Radius() const;
47 
48  ON_3dPoint PointAt(
49  double longitude_radians,
50  double latitude_radians
51  ) const; // longitude [0,2pi], latitude [-pi/2,pi/2] in radians
52 
53  ON_3dVector NormalAt(
54  double longitude_radians,
55  double latitude_radians
56  ) const; // longitude [0,2pi], latitude [-pi/2,pi/2] in radians
57 
58  ON_BoundingBox BoundingBox() const;
59 
60  // returns parameters of point on sphere that is closest to given point
61  bool ClosestPointTo(
62  ON_3dPoint test_point,
63  double* longitude_radians, // longitude [0,2pi)
64  double* latitude_radians // latitude [-pi/2,pi/2]
65  ) const;
66 
67  // returns point on sphere that is closest to given point
68  ON_3dPoint ClosestPointTo(
69  ON_3dPoint test_point
70  ) const;
71 
72  // For intersections see ON_Intersect();
73 
74  // rotate sphere about its origin
75  bool Rotate(
76  double sin_angle, // sin(angle)
77  double cos_angle, // cos(angle)
78  const ON_3dVector& axis_of_rotation // axis of rotation
79  );
80 
81  bool Rotate(
82  double angle_radians, // angle in radians
83  const ON_3dVector& axis_of_rotation // axis of rotation
84  );
85 
86  // rotate sphere about a point and axis
87  bool Rotate(
88  double sin_angle, // sin(angle)
89  double cos_angle, // cos(angle)
90  const ON_3dVector& axis_of_rotation, // axis of rotation
91  const ON_3dPoint& center_of_rotation // center of rotation
92  );
93 
94  bool Rotate(
95  double angle_radians, // angle in radians
96  const ON_3dVector& axis_of_rotation, // axis of rotation
97  const ON_3dPoint& center_of_rotation // center of rotation
98  );
99 
100  bool Translate(
101  const ON_3dVector&
102  );
103 
104  bool Transform( const ON_Xform& );
105 
106  // parameterization of NURBS surface does not match sphere's transcendental paramaterization
107  int GetNurbForm( ON_NurbsSurface& ) const; // returns 0=failure, 2=success
108 
109  /*
110  Description:
111  Creates a surface of revolution definition of the sphere.
112  Parameters:
113  bArcLengthParameterization - [in]
114  true:
115  The domain will be set to (0,radius*2*pi)x(-radius*pi/2,radius*pi/2)
116  false:
117  The domain will be set to (0,2*pi)x(-pi/2,pi/2)
118  srf - [in]
119  if not nullptr, then this srf is used.
120  Result:
121  A surface of revolution or nullptr if the sphere is not valid.
122  */
123  ON_RevSurface* RevSurfaceForm( bool bArcLengthParameterization, ON_RevSurface* srf = nullptr ) const;
124 
125  ON_DEPRECATED_MSG("Call RevSurfaceForm(false,srf)")
126  ON_RevSurface* RevSurfaceForm( ON_RevSurface* srf = nullptr ) const;
127 };
128 
129 #endif
Definition: opennurbs_nurbssurface.h:62
ON_Circle is a circle in 3d. The cirle is represented by a radius and an orthonormal frame of the pla...
Definition: opennurbs_circle.h:32
Definition: opennurbs_bounding_box.h:25
Definition: opennurbs_xform.h:28
double radius
Definition: opennurbs_sphere.h:27
ON_Plane plane
Definition: opennurbs_sphere.h:26
Definition: opennurbs_point.h:460
Definition: opennurbs_plane.h:20
surface of revolution
Definition: opennurbs_revsurface.h:21
Definition: opennurbs_point.h:1152
Definition: opennurbs_sphere.h:22