The trianglelib API reference

Routines for working with triangles.

The two modules inside of this package are packed with useful features for the programmer who needs to support triangles:

shape
This module provides a full-fledged Triangle object that can be instantiated and then asked to provide all sorts of information about its properties.
utils
For the programmer in a hurry, this module offers quick functions that take as arguments the three side lengths of a triangle, and perform a quick computation without the programmer having to make the extra step of creating an object.
advanced
Some advanced stuff.

The “shape” module

Use the triangle class to represent triangles.

class trianglelib.shape.Triangle(a, b, c)[source]

A triangle is a three-sided polygon.

area()[source]

Return the area of this triangle.

is_equilateral()[source]

Return whether this triangle is equilateral.

Returns:

bool

If the triangle is equilateral.

is_isosceles()[source]

Return whether this triangle is isoceles.

is_similar(triangle)[source]

Return whether this triangle is similar to another triangle.

perimeter()[source]

Return the perimeter of this triangle.

scale(factor)[source]

Return a new triangle, factor times the size of this one.

The “utils” module

Routines to test triangle properties without explicit instantiation.

trianglelib.utils.compute_area(a, b, c)[source]

Return the area of the triangle with side lengths a, b, and c.

If the three lengths provided cannot be the sides of a triangle, then the area 0 is returned.

trianglelib.utils.compute_perimeter(a, b, c)[source]

Return the perimeer of the triangle with side lengths a, b, and c.

If the three lengths provided cannot be the sides of a triangle, then the perimeter 0 is returned.

trianglelib.utils.is_equilateral(a, b, c)[source]

Return whether lengths a, b, and c are an equilateral triangle.

trianglelib.utils.is_isosceles(a, b, c)[source]

Return whether lengths a, b, and c are an isosceles triangle.

trianglelib.utils.is_triangle(a, b, c)[source]

Return whether lengths a, b, c can be the sides of a triangle.

Parameters:

a : float

b : float

c : float

Returns:

bool

If the sides can form a triangle

The “advaned” module

trianglelib.advanced.foo(a)[source]

A simple optimization problem.

Parameters:

a : float

The bound on the x values

Returns:

numpy.array

The value of x