-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrescent.cpp
More file actions
57 lines (45 loc) · 1.18 KB
/
Crescent.cpp
File metadata and controls
57 lines (45 loc) · 1.18 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 "Crescent.h"
#include "Point.h"
#include <glm/gtc/constants.hpp>
#include <glm/vec3.hpp>
#include <glm/glm.hpp>
Crescent::Crescent(QOpenGLShaderProgram* prog, GLfloat radius, GLuint nSlices, GLuint nStacks) :
ParametricSurface(prog, nSlices, nStacks),
_radius(radius)
{
_name = "Crescent";
buildMesh(nSlices, nStacks);
}
Crescent::~Crescent()
{
}
float Crescent::firstUParameter() const
{
return 0.0;
}
float Crescent::lastUParameter() const
{
return 1.0;
}
float Crescent::firstVParameter() const
{
return 0.0;
}
float Crescent::lastVParameter() const
{
return 1.0;
}
Point Crescent::pointAtParameter(const float& u, const float& v)
{
Point P;
float x, y, z;
//http://paulbourke.net/geometry/toroidal/
/*Crescent
Where 0 <= u <= 1, 0 <= v <= 1
*/
x = _radius * ((2 + sin(2 * glm::pi<float>() * u) * sin(2 * glm::pi<float>() * v)) * sin(3 * glm::pi<float>() * v));
y = _radius * ((2 + sin(2 * glm::pi<float>() * u) * sin(2 * glm::pi<float>() * v)) * cos(3 * glm::pi<float>() * v));
z = _radius * (cos(2 * glm::pi<float>() * u) * sin(2 * glm::pi<float>() * v) + 4 * v - 2);
P.setParam(x, y, z);
return P;
}