Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Sphere.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010, The Barbarian Group
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
6  the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and
9  the following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
11  the following disclaimer in the documentation and/or other materials provided with the distribution.
12 
13  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
14  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
15  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
17  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
19  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
20  POSSIBILITY OF SUCH DAMAGE.
21 */
22 
23 #pragma once
24 
25 #include "Vector.h"
26 #include "Ray.h"
27 
28 #include <vector>
29 
30 namespace cinder {
31 
32 class Sphere {
33  public:
34  Sphere() {}
35  Sphere( const Vec3f &aCenter, float aRadius ) : mCenter( aCenter ), mRadius( aRadius ) {}
36 
37  float getRadius() const { return mRadius; }
38  void setRadius( float radius ) { mRadius = radius; }
39 
40  const Vec3f& getCenter() const { return mCenter; }
41  const void setCenter( const Vec3f &center ) { mCenter = center; }
42 
43  bool intersects( const Ray &ray );
44  int intersect( const Ray &ray, float *intersection );
45 
46  static Sphere calculateBoundingSphere( const std::vector<Vec3f> &points );
47 
48  protected:
50  float mRadius;
51 };
52 
53 } // namespace cinder
float getRadius() const
Definition: Sphere.h:37
Definition: Ray.h:29
Sphere(const Vec3f &aCenter, float aRadius)
Definition: Sphere.h:35
float mRadius
Definition: Sphere.h:50
const void setCenter(const Vec3f &center)
Definition: Sphere.h:41
Definition: Sphere.h:32
const Vec3f & getCenter() const
Definition: Sphere.h:40
static Sphere calculateBoundingSphere(const std::vector< Vec3f > &points)
Definition: Sphere.cpp:91
void setRadius(float radius)
Definition: Sphere.h:38
Vec3f mCenter
Definition: Sphere.h:49
int intersect(const Ray &ray, float *intersection)
Definition: Sphere.cpp:59
GLsizei const GLfloat * points
Definition: GLee.h:6298
Sphere()
Definition: Sphere.h:34
bool intersects(const Ray &ray)
Definition: Sphere.cpp:29