The ray from the eye through the cursor (root frame; dir a unit vector).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(PickCamera), | intent(in) | :: | cam |
the camera and cursor of the pick |
||
| real(kind=wp), | intent(out) | :: | origin(3) |
the ray (root frame; dir: a unit vector) |
||
| real(kind=wp), | intent(out) | :: | dir(3) |
the ray (root frame; dir: a unit vector) |
pure subroutine ray(cam, origin, dir) type(PickCamera), intent(in) :: cam !! the camera and cursor of the pick real(wp), intent(out) :: origin(3), dir(3) !! the ray (root frame; dir: a unit vector) if (cam%perspective) then origin = cam%eye dir = cam%forward + cam%x * cam%tan_y * cam%aspect * cam%right + cam%y * cam%tan_y * cam%up dir = dir / norm2(dir) else origin = cam%eye + cam%right * (cam%ortho(1) + 0.5_wp * (cam%x + 1.0_wp) * (cam%ortho(2) - cam%ortho(1))) & + cam%up * (cam%ortho(3) + 0.5_wp * (cam%y + 1.0_wp) * (cam%ortho(4) - cam%ortho(3))) dir = cam%forward end if end subroutine ray