aboutsummaryrefslogtreecommitdiff
path: root/camera.go
blob: 6cc3391526d82e6f8a8b64882efc96e119af29e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

package main

// Camera handle view position and screen
type Camera struct {
	lowerLeftCorner              Vec3D
	origin, horizontal, vertical Vec3D
}

// GetRay computes Ray given screen params
func (camera Camera) GetRay(u float64, v float64) Ray {
	return Ray{
		camera.origin,
		AddVec3D(AddVec3D(
			camera.lowerLeftCorner,
			ScalarProduct(u, camera.horizontal)),
			ScalarProduct(v, camera.vertical),
		),
	}
}