-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFigure8KleinBottle.cpp
More file actions
57 lines (44 loc) · 1.22 KB
/
Figure8KleinBottle.cpp
File metadata and controls
57 lines (44 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "Figure8KleinBottle.h"
#include "Point.h"
#include <glm/gtc/constants.hpp>
#include <glm/vec3.hpp>
#include <glm/glm.hpp>
Figure8KleinBottle::Figure8KleinBottle(QOpenGLShaderProgram* prog, GLfloat radius, GLuint nSlices, GLuint nStacks) :
ParametricSurface(prog, nSlices, nStacks),
_radius(radius)
{
_name = "Figure 8 Klein Bottle";
buildMesh(nSlices, nStacks);
}
Figure8KleinBottle::~Figure8KleinBottle()
{
}
float Figure8KleinBottle::firstUParameter() const
{
return 0.0;
}
float Figure8KleinBottle::lastUParameter() const
{
return glm::two_pi<float>();
}
float Figure8KleinBottle::firstVParameter() const
{
return 0.0;
}
float Figure8KleinBottle::lastVParameter() const
{
return glm::two_pi<float>();
}
Point Figure8KleinBottle::pointAtParameter(const float& u, const float& v)
{
Point P;
float x, y, z;
//http://paulbourke.net/geometry/toroidal/
// Figure-8 Klein bottle
// Where u = 0 - 2PI and v = 0 - 2PI
x = _radius * (2 + cos(v / 2)* sin(u) - sin(v / 2)* sin(2 * u))* cos(v);
y = _radius * (2 + cos(v / 2)* sin(u) - sin(v / 2)* sin(2 * u))* sin(v);
z = _radius * (sin(v / 2)* sin(u) + cos(v / 2) *sin(2 * u));
P.setParam(x, y, z);
return P;
}