struct Rosegold::Look

Overview

The unit circle of yaw on the XZ-plane has 0° at (0, 1), 90° at (-1, 0), 180° at (0, -1) and 270° at (1, 0).

Yaw is not clamped to between 0° and 360°; any number is valid, including negative numbers and numbers greater than 360°.

Pitch 0 is looking straight ahead, -90° is looking straight up, and 90° is looking straight down.

There are an infinite number of "down"/"up" looks with different yaw; use e.g. NORTH.down.

Defined in:

rosegold/world/look.cr

Constant Summary

EAST = self.new(270, 0)

Faces positive X on the horizontal plane.

NORTH = self.new(180, 0)

Faces negative Z on the horizontal plane.

SOUTH = self.new(0, 0)

Faces positive Z on the horizontal plane.

WEST = self.new(90, 0)

Faces negative X on the horizontal plane.

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(yaw : Float32, pitch : Float32) #

Creates a direction from yaw and pitch in degrees. Angles are stored as given.


[View source]

Class Method Detail

def self.from_rad(yaw_rad : Float32, pitch_rad : Float32) #

Builds a direction from yaw and pitch in radians.


[View source]
def self.from_vec(vec : Vec3d | Vec3f) #

Builds a direction that points along vec.


[View source]
def self.wrap_yaw(yaw : Float32) : Float32 #

Normalizes a yaw angle to the half-open range -180 through 180 degrees. Returns 0 for NaN or infinite input.


[View source]

Instance Method Detail

def down(angle : Float32 = 90) #

Returns a copy looking downward by angle degrees while retaining yaw.


[View source]
def inspect(io) #

Writes a compact yaw/pitch representation for debugging.


[View source]
def pitch : Float32 #

Vertical facing angle in degrees; negative looks up and positive looks down.


[View source]
def pitch_rad #

The pitch angle in radians.


[View source]
def to_vec3 #

Converts this direction to a unit world-space vector.


[View source]
def up(angle : Float32 = 90) #

Returns a copy looking upward by angle degrees while retaining yaw.


[View source]
def with_pitch(pitch : Float32) #

Returns a copy with pitch in degrees and the existing yaw.


[View source]
def with_pitch(pitch : Float64) #

Returns a copy with a Float64 pitch converted to Float32.


[View source]
def with_yaw(yaw : Float32) #

Returns a copy with yaw in degrees and the existing pitch.


[View source]
def with_yaw(yaw : Float64) #

Returns a copy with a Float64 yaw converted to Float32.


[View source]
def yaw : Float32 #

Horizontal facing angle in degrees.


[View source]
def yaw_rad #

The yaw angle in radians.


[View source]