Skip to content

Commit

Permalink
add function to calculate right triangle base length from angle
Browse files Browse the repository at this point in the history
  • Loading branch information
harbdog committed Apr 26, 2024
1 parent be264a9 commit 8359877
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions geom/geometry.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,15 @@ func (c *Circle) CircleCollision(c2 *Circle) (float64, bool) {
return distance, collision
}

// GetOppositeTriangleLeg gets the leg length opposite another non-hypotenuse leg in a right triangle
func GetOppositeTriangleLeg(angle, legLength float64) float64 {
opposite := legLength * math.Tan(angle)
// GetOppositeTriangleBase gets the base length opposite the non-hypotenuse leg in a right triangle
func GetOppositeTriangleBase(angle, oppositeLength float64) float64 {
base := oppositeLength / math.Tan(angle)
return base
}

// GetOppositeTriangleLeg gets the leg length opposite the non-hypotenuse base in a right triangle
func GetOppositeTriangleLeg(angle, baseLength float64) float64 {
opposite := baseLength * math.Tan(angle)
return opposite
}

Expand Down

0 comments on commit 8359877

Please sign in to comment.