-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEye.cpp
executable file
·28 lines (27 loc) · 1.1 KB
/
Eye.cpp
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
#include "Eye.h"
Eye::Eye(MyVector pos, MyVector LookAt, double distance, MyVector verticalVector, double dimPixel, int width, int height) : position(pos), LookAt(LookAt), distanceToMatrix(distance), verticalVector(verticalVector), dimPixel(dimPixel), width(width), height(height)
{
direction = LookAt - position;
direction.normalize();
verticalVector.normalize();
centerOfPlain = position + (direction * distanceToMatrix);
horizontalVector = MyVector(crossProduct(direction, verticalVector));
horizontalVector.absoluteValue();
TopLeftPlain = centerOfPlain + ((-1 * horizontalVector) * (dimPixel * width / 2) + verticalVector * (dimPixel * height / 2));
// TopLeftPlain.printVec();
// centerOfPlain.printVec();
}
MyVector Eye::blur(float radius)
{
if (radius != 0)
{
double randX = rand() % 100 - 50;
double randY = rand() % 100 - 50;
double randZ = rand() % 100 - 50;
MyVector randomVector(randX, randY, randZ);
randomVector.normalize();
randomVector *= radius;
return position + randomVector;
}
return position;
}