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