ichigo/engine/projection.go
Josh Deprez 03e5e7ca49 prisms
2021-09-05 20:54:43 +10:00

24 lines
694 B
Go

package engine
var (
// Oblique projections
CabinetProjection = ParallelProjection{0.5, 0.5}
CavalierProjection = ParallelProjection{1, 1}
// Axonometric projections
DimetricProjection = ParallelProjection{0, 0.5}
ElevationProjection = ParallelProjection{0, 0}
IsometricProjection = ParallelProjection{0, 0.707106781186548} // 1 ÷ √2
TrimetricProjection = ParallelProjection{0, 1}
HexPrismProjection = ParallelProjection{0, 0.816496580927726} // √2 ÷ √3
)
type ParallelProjection struct {
ZX, ZY float64
}
func (π ParallelProjection) Project(p Point3) (px, py float64) {
px = float64(p.X) + π.ZX*float64(p.Z)
py = float64(p.Y) + π.ZY*float64(p.Z)
return px, py
}