Method: Joules.trapezium_area

Defined in:
lib/joules/geometry.rb

.trapezium_area(top_base, bottom_base, height) ⇒ Float

Calculates the area of a trapezium given top base, bottom base, and height.

Examples:

Joules.trapezium_area(10, 15, 3) #=> 37.5

Parameters:

  • top_base (Int, Float)

    top_base >= 0; top_base is in a unit of length

  • bottom_base (Int, Float)

    bottom_base >= 0; bottom_base has the same units as top_base

  • height (Int, Float)

    height >= 0; height has the same units as top_base

Returns:

  • (Float)

    return value >= 0; return value has the same units squared as top_base



72
73
74
# File 'lib/joules/geometry.rb', line 72

def trapezium_area(top_base, bottom_base, height)
  return 0.5 * (top_base + bottom_base) * height
end