1 /*******************************************************************************
2  * super.h
3  *
4  * This module contains all defines, typedefs, and prototypes for SUPEREL.CPP.
5  *
6  * ---------------------------------------------------------------------------
7  * Persistence of Vision Ray Tracer ('POV-Ray') version 3.7.
8  * Copyright 1991-2013 Persistence of Vision Raytracer Pty. Ltd.
9  *
10  * POV-Ray is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as
12  * published by the Free Software Foundation, either version 3 of the
13  * License, or (at your option) any later version.
14  *
15  * POV-Ray is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  * ---------------------------------------------------------------------------
23  * POV-Ray is based on the popular DKB raytracer version 2.12.
24  * DKBTrace was originally written by David K. Buck.
25  * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
26  * ---------------------------------------------------------------------------
27  * $File: //depot/public/povray/3.x/source/backend/shape/super.h $
28  * $Revision: #1 $
29  * $Change: 6069 $
30  * $DateTime: 2013/11/06 11:59:40 $
31  * $Author: chrisc $
32  *******************************************************************************/
33 
34 #ifndef SUPER_H
35 #define SUPER_H
36 
37 namespace pov
38 {
39 
40 /*****************************************************************************
41 * Global preprocessor definitions
42 ******************************************************************************/
43 
44 #define SUPERELLIPSOID_OBJECT (BASIC_OBJECT)
45 
46 
47 
48 /*****************************************************************************
49 * Global typedefs
50 ******************************************************************************/
51 
52 class Superellipsoid : public ObjectBase
53 {
54 	public:
55 		VECTOR Power;
56 
57 		Superellipsoid();
58 		virtual ~Superellipsoid();
59 
60 		virtual ObjectPtr Copy();
61 
62 		virtual bool All_Intersections(const Ray&, IStack&, TraceThreadData *);
63 		virtual bool Inside(const VECTOR, TraceThreadData *) const;
64 		virtual void Normal(VECTOR, Intersection *, TraceThreadData *) const;
65 		virtual void Translate(const VECTOR, const TRANSFORM *);
66 		virtual void Rotate(const VECTOR, const TRANSFORM *);
67 		virtual void Scale(const VECTOR, const TRANSFORM *);
68 		virtual void Transform(const TRANSFORM *);
69 		virtual void Invert();
70 		virtual void Compute_BBox();
71 	protected:
72 		bool Intersect(const Ray& ray, IStack& Depth_Stack, TraceThreadData *Thread);
73 		static bool intersect_box(const VECTOR P, const VECTOR D, DBL *dmin, DBL *dmax);
74 		static DBL power(DBL x, DBL e);
75 		static DBL evaluate_g(DBL x, DBL y, DBL e);
76 		DBL evaluate_superellipsoid(const VECTOR P) const;
77 		static int compdists(const void *in_a, const void *in_b);
78 		int find_ray_plane_points(const VECTOR P, const VECTOR D, int cnt, DBL *dists, DBL mindist, DBL maxdist) const;
79 		void solve_hit1(DBL v0, const VECTOR tP0, DBL v1, const VECTOR tP1, VECTOR P) const;
80 		bool check_hit2(const VECTOR P, const VECTOR D, DBL t0, VECTOR P0, DBL v0, DBL t1, DBL *t, VECTOR Q) const;
81 		bool insert_hit(const Ray& ray, DBL Depth, IStack& Depth_Stack, TraceThreadData *Thread);
82 };
83 
84 }
85 
86 #endif
87