-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint.cpp
More file actions
42 lines (33 loc) · 746 Bytes
/
point.cpp
File metadata and controls
42 lines (33 loc) · 746 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<stdlib.h>
#include"vector3.h"
#include"point.h"
void Point::set(float nX, float nY, float nZ) {
x = nX;
y = nY;
z = nZ;
w = 1;
}
void Point::setlerp(const Point& p, float b) {
setlerp(*this, p, b);
}
void Point::setlerp(const Point & p, const Point& q, float b) {
float nX, nY, nZ;
float nB = 1 - b;
nX = (nB * p.x) + (b * q.x);
nY = (nB * p.y) + (b * q.y);
nZ = (nB * p.z) + (b * q.z);
x = nX;
y = nY;
z = nZ;
}
Point Point::lerp(const Point& p, float b) {
return lerp(*this, p, b);
}
Point Point::lerp(const Point& p, const Point& q, float b) {
Point ret;
float nB = 1 - b;
ret.x = (nB * p.x) + (b * q.x);
ret.y = (nB * p.y) + (b * q.y);
ret.z = (nB * p.z) + (b * q.z);
return ret;
}