Skip to content

Commit

Permalink
cube/rotation.go: Add new Neg method.
Browse files Browse the repository at this point in the history
Also fixed Opposite()[1] having incorrect values if r[1] is outside normal bounds.
  • Loading branch information
Sandertv committed Dec 15, 2024
1 parent c8b4614 commit 7b1cc29
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/block/cube/rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ func (r Rotation) Add(r2 Rotation) Rotation {
// Opposite returns the Rotation opposite r, so that
// r.Vec3().Add(r.Opposite().Vec3()).Len() is equal to 0.
func (r Rotation) Opposite() Rotation {
return Rotation{r[0] + 180, -r[1]}.fix()
fixed := r.fix()
return Rotation{fixed[0] + 180, -fixed[1]}.fix()
}

// Neg returns the negation of the Rotation. It is equivalent to creating a new
// Rotation{-r[0], -r[1]}.
func (r Rotation) Neg() Rotation {
fixed := r.fix()
return Rotation{-fixed[0], -fixed[1]}
}

// Direction returns the horizontal Direction that r points towards based on the
Expand Down

0 comments on commit 7b1cc29

Please sign in to comment.