-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRay.cpp
More file actions
34 lines (27 loc) · 691 Bytes
/
Ray.cpp
File metadata and controls
34 lines (27 loc) · 691 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
#include "StdAfx.h"
#include "Ray.h"
void Ray::Normalize(Point input)
{
float modR = sqrt((input.x * input.x) + (input.y* input.y) + (input.z * input.z));
input.x = input.x / modR;
input.y = input.y / modR;
input.z = input.z / modR;
}
Point Ray::VectorMult(Point x, float t)
{
Point temp = { x.x * t, x.y * t, x.z * t };
return temp;
}
Ray Ray::CalculateRay(float head[3], float origin[3]) {
Point Pos, Dir;
Pos.x = origin[0];
Pos.y = origin[1];
Pos.z = origin[2];
Dir.x = head[0] - origin[0];
Dir.y = head[1] - origin[1];
Dir.z = head[2] - origin[2];
return Ray(Pos, Dir);
}
float Point::DotProduct(Point a, Point b) {
return (a.x * b.x) + (a.y * b.y) + (a.z * b.z);
}