GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
IntersectionCurve.hh
Go to the documentation of this file.
1
2#include "Effect.hh"
3
4class IntersectionCurve : public Curve<Point>
5{
6public:
7 IntersectionCurve(SphereSurfaceIn3d &sphere1, SphereSurfaceIn3d &sphere2) : sphere1(sphere1), sphere2(sphere2) { }
8
9private:
10 SphereSurfaceIn3d &sphere1;
11 SphereSurfaceIn3d &sphere2;
12};
13
14
15//
16// Proper intersections
17//
18
19class IntersectionPrimitive2d : public Function<float, Point2d>, public Function<Point2d, float>
20{
21public:
22 Point2d Index(float val) const { return Curve(val); }
23 float Index(Point2d p) const { return Distance(p); }
24
25 virtual Point2d Curve(float val) const=0;
26 virtual float Distance(Point2d p) const=0;
27 virtual float StartRange() const =0;
28 virtual float EndRange() const=0;
29};
30
32{
33 SolvableCompose<Point2d> compose(p1,p2);
34 float intersectionpoint = Solve(compose, p1.StartRange(), p1.EndRange());
35 return intersectionpoint;
36}
38{
39 SolvableCompose<Point2d> compose(p2,p1);
40 float intersectionpoint = Solve(compose, p2.StartRange(), p2.EndRange());
41 return intersectionpoint;
42}
43
44class IntersectionPrimitive3d : public Function<float, Point2d>, public Function<Point2d,Point>, public Function<Point, float>
45{
46public:
47 void set_curve(CurveIn3d &curve) { m_curve = &curve; }
48 Point2d Index(float val) const { return Retraction(*m_curve, val); }
49 Point Index(Point2d val) const { return Surface(val); }
50 float Index(Point p) const { return DistanceFromSurface(p); }
51 virtual Point2d Retraction(const CurveIn3d &curve, float pos) const=0;
52 virtual Point Surface(Point2d p) const=0;
53 // distance is negative if inside, positive if outside
54 virtual float DistanceFromSurface(Point p) const=0;
55 virtual float StartRange() const =0;
56 virtual float EndRange() const=0;
57private:
58 CurveIn3d *m_curve;
59};
60
62{
63public:
64 SpherePrimitive(Point center, float radius) : center(center), radius(radius) { }
65 virtual Point2d Retraction(const CurveIn3d &curve, float pos) const
66 {
67
68 }
69 virtual Point Surface(Point2d p) const=0;
70 virtual float DistanceFromSurface(Point p) const=0;
71 virtual float StartRange() const =0;
72 virtual float EndRange() const=0;
73};
74
76{
78 FunctionCompose<float, Point, float> compose2(compose1, p2);
79 float intersectionpoint = Solve(compose2, p1.StartRange(), p1.EndRange());
80 return intersectionpoint;
81}
83{
85 FunctionCompose<float, Point, float> compose2(compose1, p1);
86 float intersectionpoint = Solve(compose2, p2.StartRange(), p2.EndRange());
87 return intersectionpoint;
88}
89
90
91template<class T>
93{
94public:
95 virtual Color MapColor(T t) const=0;
96};
float Solve(const Function< float, float > &func, float t_0, float t_1)
Definition Effect.cc:1836
float Intersection1(IntersectionPrimitive2d &p1, IntersectionPrimitive2d &p2)
Definition IntersectionCurve.hh:31
ColorSpace< Point > ColorSpace3d
Definition IntersectionCurve.hh:98
float Intersection2(IntersectionPrimitive2d &p1, IntersectionPrimitive2d &p2)
Definition IntersectionCurve.hh:37
ColorSpace< Point2d > ColorSpace2d
Definition IntersectionCurve.hh:97
Definition IntersectionCurve.hh:93
virtual Color MapColor(T t) const =0
Definition VectorTools.hh:380
Definition EffectI.hh:49
Definition EffectI.hh:30
Definition Effect.hh:490
Definition EffectI.hh:11
IntersectionCurve(SphereSurfaceIn3d &sphere1, SphereSurfaceIn3d &sphere2)
Definition IntersectionCurve.hh:7
Definition IntersectionCurve.hh:20
Point2d Index(float val) const
Definition IntersectionCurve.hh:22
virtual float Distance(Point2d p) const =0
virtual float StartRange() const =0
float Index(Point2d p) const
Definition IntersectionCurve.hh:23
virtual Point2d Curve(float val) const =0
virtual float EndRange() const =0
Definition IntersectionCurve.hh:45
virtual float StartRange() const =0
float Index(Point p) const
Definition IntersectionCurve.hh:50
Point Index(Point2d val) const
Definition IntersectionCurve.hh:49
void set_curve(CurveIn3d &curve)
Definition IntersectionCurve.hh:47
virtual Point Surface(Point2d p) const =0
Point2d Index(float val) const
Definition IntersectionCurve.hh:48
virtual float EndRange() const =0
virtual float DistanceFromSurface(Point p) const =0
virtual Point2d Retraction(const CurveIn3d &curve, float pos) const =0
Definition Effect.hh:10172
virtual float StartRange() const =0
virtual float EndRange() const =0
virtual float DistanceFromSurface(Point p) const =0
SpherePrimitive(Point center, float radius)
Definition IntersectionCurve.hh:64
virtual Point Surface(Point2d p) const =0
virtual Point2d Retraction(const CurveIn3d &curve, float pos) const
Definition IntersectionCurve.hh:65
border radius
Definition gameapi_example.php:45
Definition VectorTools.hh:910
Definition Parser.cc:60
Definition GameApi.h:42