-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisk.cpp
More file actions
42 lines (34 loc) · 864 Bytes
/
Copy pathDisk.cpp
File metadata and controls
42 lines (34 loc) · 864 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
#include "Disk.h"
#include "Utility.h"
// Default constructor
Disk::Disk() {
}
// Create a disk with a given radius
Disk::Disk(float radius) {
m_radius = radius;
}
// Create a disk along a specified plane with a given radius
Disk::Disk(float radius, Vector plane) {
m_radius = radius;
m_plane = plane;
}
// Setter: sets the radius of the disk
void Disk::setRadius(float radius) {
m_radius = radius;
}
// Getter: gets the radius of the disk
float Disk::getRadius() {
return m_radius;
}
// Intersection test for the plane
bool Disk::intersectsDisk(Vector& n, Vector& p0, Vector& l0, Vector l, IntersectInfo& i) {
i.t = 0;
Utility util;
if (intersectsPlane(n, p0, l0, l, i)) {
Vector p = l0 + l * i.t;
Vector v = p - p0;
float d2 = util.dot3D(v, v);
return (sqrtf(d2) <= m_radius);
}
return false;
}