Module

Hylograph.Isometric.Camera

Package
purescript-hylograph-isometric
Repository
afcondon/purescript-hylograph-isometric

An orthographic camera: two angles and a scale.

The world is the coordinate system of a 2D layout with height added: x and y are the layout's own (so y grows "down the page", which on the floor means towards the south), and z is up. A layout placed on the floor keeps its coordinates and gains a z.

The camera looks at the world from a horizontal direction, its azimuth (measured in the floor from +x towards +y), and from an elevation above the floor. Isometric is one setting: azimuth 45° and elevation asin (1 / √3) ≈ 35.26°, from which the three axes are drawn at equal length, x and y at ±30° below the horizontal and z straight up.

There is no perspective, deliberately: an orthographic view keeps lengths along an axis comparable wherever they are in the picture.

#Point Source

type Point = { x :: Number, y :: Number }

A point on the screen (SVG user units, y down), or in a 2D layout.

#Point3 Source

type Point3 = { x :: Number, y :: Number, z :: Number }

A point in the world: a layout's x and y, and a height z.

#Degrees Source

newtype Degrees

An angle in degrees. The camera's angles are kept in degrees because that is how they are chosen and read; radians converts.

Constructors

Instances

#Camera Source

newtype Camera

scale is screen units per world unit along the line of sight's perpendicular plane (a true orthographic scale): a unit along an axis is drawn shorter than scale by the cosine of its angle to that plane.

Constructors

Instances

#Viewpoint Source

data Viewpoint

The four isometric viewpoints, a quarter turn apart, named for the corner of the floor the camera stands beyond (y grows to the south).

Constructors

Instances

#isometric Source

isometric :: Camera

The isometric camera from the south-east, at scale 1.

#isometricUnit Source

isometricUnit :: Number -> Camera

The isometric camera (from the south-east) at the scale that draws a unit along any axis length screen units long.

#turnedBy Source

turnedBy :: Degrees -> Camera -> Camera

The camera turned about the vertical through the origin.

#nextViewpoint Source

nextViewpoint :: Viewpoint -> Viewpoint

A quarter turn of the camera, anticlockwise seen from above (azimuth + 90°).

#between Source

between :: Number -> Camera -> Camera -> Camera

The camera a fraction t of the way from one to the other, every parameter linearly (the azimuth as given, not reduced: to turn the short way, give azimuths less than 180° apart).

#project Source

project :: Camera -> Point3 -> Point

Where a point of the world is drawn: SVG user units, y down, the world's origin at the screen's.

#depth Source

depth :: Camera -> Point3 -> Number

How near a point is to the camera, along the line of sight: larger is nearer. Only differences mean anything.

#towardsCamera Source

towardsCamera :: Camera -> Point3

The unit vector from the scene towards the camera.

#floorTowardsCamera Source

floorTowardsCamera :: Camera -> Point

The horizontal direction towards the camera, as a unit vector in the floor.

#screenRight Source

screenRight :: Camera -> Point

The horizontal unit vector that the camera draws pointing right.