struct
Rosegold::Look
- Rosegold::Look
- Struct
- Value
- Object
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.crConstant 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
-
.new(yaw : Float32, pitch : Float32)
Creates a direction from yaw and pitch in degrees.
Class Method Summary
-
.from_rad(yaw_rad : Float32, pitch_rad : Float32)
Builds a direction from yaw and pitch in radians.
-
.from_vec(vec : Vec3d | Vec3f)
Builds a direction that points along vec.
-
.wrap_yaw(yaw : Float32) : Float32
Normalizes a yaw angle to the half-open range -180 through 180 degrees.
Instance Method Summary
-
#down(angle : Float32 = 90)
Returns a copy looking downward by angle degrees while retaining yaw.
-
#inspect(io)
Writes a compact yaw/pitch representation for debugging.
-
#pitch : Float32
Vertical facing angle in degrees; negative looks up and positive looks down.
-
#pitch_rad
The pitch angle in radians.
-
#to_vec3
Converts this direction to a unit world-space vector.
-
#up(angle : Float32 = 90)
Returns a copy looking upward by angle degrees while retaining yaw.
-
#with_pitch(pitch : Float32)
Returns a copy with pitch in degrees and the existing yaw.
-
#with_pitch(pitch : Float64)
Returns a copy with a Float64 pitch converted to Float32.
-
#with_yaw(yaw : Float32)
Returns a copy with yaw in degrees and the existing pitch.
-
#with_yaw(yaw : Float64)
Returns a copy with a Float64 yaw converted to Float32.
-
#yaw : Float32
Horizontal facing angle in degrees.
-
#yaw_rad
The yaw angle in radians.
Constructor Detail
Creates a direction from yaw and pitch in degrees. Angles are stored as given.
Class Method Detail
Builds a direction from yaw and pitch in radians.
Normalizes a yaw angle to the half-open range -180 through 180 degrees.
Returns 0 for NaN or infinite input.
Instance Method Detail
Returns a copy looking downward by angle degrees while retaining yaw.