-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCamera.cs
30 lines (26 loc) · 905 Bytes
/
Camera.cs
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
using System.Numerics;
namespace _12_Dielectrics
{
public class Camera
{
private Vector3 origin;
private Vector3 lower_left_corner;
private Vector3 horizontal;
private Vector3 vertical;
public Camera()
{
var aspect_ratio = 16.0f / 9.0f;
var viewport_height = 2.0f;
var viewport_width = aspect_ratio * viewport_height;
var focal_length = 1.0f;
origin = Vector3.Zero;
horizontal = new Vector3(viewport_width, 0.0f, 0.0f);
vertical = new Vector3(0.0f, viewport_height, 0.0f);
lower_left_corner = origin - horizontal / 2 - vertical / 2 - new Vector3(0, 0, focal_length);
}
public Ray Get_Ray(float u, float v)
{
return new Ray(origin, lower_left_corner + u * horizontal + v * vertical - origin);
}
}
}