Added angle radian conversion

This commit is contained in:
arvid schröder 2022-11-06 20:08:09 +01:00
parent 7c83ece187
commit 61ec153832

View file

@ -27,12 +27,11 @@ Ray PerspectiveCamera::createRay(float x, float y) const {
// Set up a left-handed coordinate system, // Set up a left-handed coordinate system,
// in which the camera looks along the positive z-Axis // in which the camera looks along the positive z-Axis
float angle_x = x * this->fovAngle; float angle_x = x * this->fovAngle * 2 * PI / 360;
float angle_y = y * this->fovAngle; float angle_y = y * this->fovAngle * 2 * PI / 360;
Vector3d rotationVector = crossProduct(forwardDirection, upDirection); Vector3d rotationVector = crossProduct(forwardDirection, upDirection);
Vector3d rotated_x = rotateVector(forwardDirection, upDirection, angle_x); Vector3d rotated_x = rotateVector(forwardDirection, upDirection, angle_x);
Vector3d directionVector = rotateVector(rotated_x, rotationVector, angle_y); Vector3d directionVector = rotateVector(rotated_x, rotationVector, angle_y);
return Ray {this->position, directionVector}; return Ray {this->position, directionVector};
} }