Geometry
Constants
Polymath.Geometry.PI
— ConstantConstant representing the value of π (pi).
Example
julia> PI
3.141592653589793
Types
Polymath.Geometry.Point
— TypePoint(x, y)
Point(x, y, z)
Structure containing 2D or 3D coordinates.
Examples
julia> p1 = Point(1, 2, 3)
Point(1, 2, 3)
julia> p2 = Point(4, 5)
Point(4, 5, nothing)
Functions
Polymath.Geometry.circumference
— Functioncircumference(radius)
Calculate circumference given the radius.
Example
julia> circumference(32.50)
204.20352248333654
Polymath.Geometry.diameter
— Functiondiameter(radius)
Calculate diameter given the radius.
Example
julia> diameter(17.75)
35.5
Polymath.Geometry.radius
— Functionradius(diameter)
Calculate radius given the diameter.
Example
julia> radius(54.25)
27.125
Polymath.Geometry.area_circle
— Functionarea_circle(radius)
Calculate area of a circle given the radius.
Example
julia> area_circle(157)
77437.11731833481
Polymath.Geometry.area_cube
— Functionarea_cube(side_length)
Calculate area of a cube given the length of a side.
Example
julia> area_cube(42)
10584
Polymath.Geometry.area_ellipse
— Functionarea_ellipse(major_semiaxis, minor_semiaxis)
Calculate area of an ellipse given the major and minor semiaxes.
Example
julia> area_ellipse(50.575, 50.419)
8010.875677067962
Polymath.Geometry.area_rectangle
— Functionarea_rectangle(height, width)
Calculate area of a rectangle given the height and width.
Example
julia> area_rectangle(15.75, 20)
315.0
Polymath.Geometry.area_square
— Functionarea_square(side_length)
Calculate area of a square given the length of a side.
Example
julia> area_square(25.50)
650.25
Polymath.Geometry.area_trapezoid
— Functionarea_trapezoid(base_length, top_length, height)
Calculate area of a trapezoid given the base length, top length, and height.
Example
julia> area_trapezoid(30.5, 10.5, 20.75)
425.375
Polymath.Geometry.area_triangle
— Functionarea_triangle(base_length, height)
Calculate area of a triangle given the base length and height.
Example
julia> area_triangle(42.5, 32.50)
690.625
Polymath.Geometry.perimeter_rectangle
— Functionperimeter_rectangle(height, width)
Calculate perimeter of a rectangle given the height and width.
Example
julia> perimeter_rectangle(25, 50)
150
Polymath.Geometry.perimeter_square
— Functionperimeter_square(side_length)
Calculate perimeter of a square given the length of a side.
Example
julia> perimeter_square(25)
100
Polymath.Geometry.perimeter_triangle
— Functionperimeter_triangle(side_a, side_b, side_c)
Calculate perimeter of a triangle given the length of the sides.
Example
julia> perimeter_triangle(10, 20, 30)
60
Polymath.Geometry.edges
— Functionedges(faces, vertices)
Calculate edges of a convex polyhedron given the faces and vertices.
Example
julia> edges(6, 8)
12
Polymath.Geometry.faces
— Functionfaces(edges, vertices)
Calculate faces of convex polyhedron given the edges and vertices.
Example
julia> faces(12, 8)
6
Polymath.Geometry.vertices
— Functionvertices(edges, faces)
Calculate vertices of a convex polyhedron given the edges and faces.
Example
julia> vertices(12, 6)
8
Polymath.Geometry.has_euler_characteristic
— Functionhas_euler_characteristic(edges, faces, vertices)
Determine whether or not a polyhedron has the Euler characteristic given the edges, faces, and vertices.
Examples
julia> has_euler_characteristic(6, 4, 4) # tetrahedron
true
julia> has_euler_characteristic(12, 7, 6) # tetrahemihexahedron
false
Polymath.Geometry.pytheorem
— Functionpytheorem(leg_a, leg_b)
Calculate (using the Pythagorean theorem) area of the square formed along the hypotenuse of a right triangle given the length of the legs.
Examples
julia> pytheorem(3, 7)
58
julia> hypotenuse_length(3, 7) ^ 2
58
Polymath.Geometry.hypotenuse_length
— Functionhypotenuse_length(leg_a, leg_b)
Calculate length of a hypotenuse given the length of the legs. The hypotenuse is the longest side of a right triangle and is opposite of the 90° angle.
Examples
julia> hypotenuse_length(4, 7)
8.06225774829855
julia> sqrt(pytheorem(4, 7))
8.06225774829855
Polymath.Geometry.leg_length
— Functionleg_length(leg, hypotenuse)
Calculate length of a missing right triangle leg given the lengths of an existing leg and the hypotenuse.
Example
julia> leg_length(4, 8.0623)
7.000048663402277
Polymath.Geometry.distance_2d
— Functiondistance_2d(x1, y1, x2, y2)
distance_2d(p1, p2)
Calculate distance between a pair of 2D points given the coordinates.
Examples
julia> distance_2d(25, 42, 35, 80)
39.293765408777
julia> p1 = Point(25, 42)
Point(25, 42, nothing)
julia> p2 = Point(35, 80)
Point(35, 80, nothing)
julia> distance_2d(p1, p2)
39.293765408777
Polymath.Geometry.distance_3d
— Functiondistance_3d(x1, y1, z1, x2, y2, z2)
distance_3d(p1, p2)
Calculate distance between a pair of 3D points given the coordinates.
Examples
julia> distance_3d(14, 8, 5, 17, 38, 23)
35.11409973215888
julia> p1 = Point(14, 8, 5)
Point(14, 8, 5)
julia> p2 = Point(17, 38, 23)
Point(17, 38, 23)
julia> distance_3d(p1, p2)
35.11409973215888