omdl
v0.9.5
OpenSCAD Mechanical Design Library
|
Triangle mathematical functions. More...
Files | |
file | triangle.scad |
Triangle shapes, conversions, properties, and tests functions. | |
Shapes | |
function | triangle_ppp2sss (c) |
Compute the side lengths of a triangle given its vertex coordinates. More... | |
function | triangle_sas2sss (v) |
Compute the side lengths of a triangle given two sides and the included angle. More... | |
function | triangle_asa2sss (v) |
Compute the side lengths of a triangle given a side and two adjacent angles. More... | |
function | triangle_aas2sss (v) |
Compute the side lengths of a triangle given a side, one adjacent and the opposite angle. More... | |
function | triangle2d_sss2ppp (v, a=x_axis_ci, cw=true) |
Compute a set of vertex coordinates for a triangle given its side lengths in 2D. More... | |
Properties | |
function | triangle2d_area (c, s=false) |
Compute the area of a triangle given its vertex coordinates in 2D. More... | |
function | triangle_centroid (c, d=2) |
Compute the centroid of a triangle. More... | |
function | triangle2d_incenter (c) |
Compute the center coordinate of a triangle's incircle in 2D. More... | |
function | triangle2d_inradius (c) |
Compute the inradius of a triangle's incircle in 2D. More... | |
function | triangle2d_excenter (c, v=1) |
Compute the center coordinate of a triangle's excircle in 2D. More... | |
function | triangle2d_exradius (c, v=1) |
Compute the exradius of a triangle's excircle in 2D. More... | |
function | triangle_circumcenter (c, d=2) |
Compute the coordinate of a triangle's circumcenter. More... | |
Tests | |
function | triangle2d_is_cw (c) |
Test the vertex ordering, or orientation, of a triangle in 2D. More... | |
function | triangle2d_is_pit (c, p) |
Test if a point is inside a triangle in 2d. More... | |
Rounding | |
function | triangle2d_vround3_center (c, r) |
Compute the rounding center coordinate for a given radius of a triangle vertex in 2D. More... | |
function | triangle2d_vround3_tangents (c, r) |
Compute the rounding tangent coordinates for a given radius of a triangle vertex in 2D. More... | |
Triangle mathematical functions.
Requires: |
---|
include <omdl-base.scad>; |
See Wikipedia for more information.
function triangle2d_area | ( | c | , |
s | = false |
||
) |
Compute the area of a triangle given its vertex coordinates in 2D.
c | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
s | <boolean> Return the vertex ordering sign. |
function triangle2d_excenter | ( | c | , |
v | = 1 |
||
) |
Compute the center coordinate of a triangle's excircle in 2D.
c | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
v | <integer> Return coordinate opposite vertex v . |
A circle outside of the triangle specified by v1
, v2
, and v3
, tangent to the side opposite v
and tangent to the extensions of the other two sides away from v
. See Wikipedia for more information.
function triangle2d_exradius | ( | c | , |
v | = 1 |
||
) |
Compute the exradius of a triangle's excircle in 2D.
c | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
v | <integer> Return coordinate opposite vertex v . |
v
.See Wikipedia for more information.
function triangle2d_incenter | ( | c | ) |
Compute the center coordinate of a triangle's incircle in 2D.
c | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
The interior point for which distances to the sides of the triangle are equal. See Wikipedia for more information.
function triangle2d_inradius | ( | c | ) |
Compute the inradius of a triangle's incircle in 2D.
c | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
See Wikipedia for more information.
function triangle2d_is_cw | ( | c | ) |
Test the vertex ordering, or orientation, of a triangle in 2D.
c | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
function triangle2d_is_pit | ( | c | , |
p | |||
) |
Test if a point is inside a triangle in 2d.
c | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
p | <point-2d> A test point coordinate [x, y]. |
See Wikipedia for more information.
function triangle2d_sss2ppp | ( | v | , |
a | = x_axis_ci , |
||
cw | = true |
||
) |
Compute a set of vertex coordinates for a triangle given its side lengths in 2D.
v | <decimal-list-3> A list, [s1, s2, s3], the side lengths. |
a | <integer> The axis alignment index < x_axis_ci | y_axis_ci >. |
cw | <boolean> Order vertices clockwise. |
cw
= true, else [v1, v3, v2].Each side length is opposite the corresponding vertex. The triangle will be constructed with v1 at the origin. Side s2 will be on the 'x' axis or side s3 will be on the 'y' axis as determined by parameter a
.
Object example
No verification is performed to ensure that the given sides specify a valid triangle. See Wikipedia for more information.
function triangle2d_vround3_center | ( | c | , |
r | |||
) |
Compute the rounding center coordinate for a given radius of a triangle vertex in 2D.
c | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
r | <decimal> The vertex rounding radius. |
function triangle2d_vround3_tangents | ( | c | , |
r | |||
) |
Compute the rounding tangent coordinates for a given radius of a triangle vertex in 2D.
c | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
r | <decimal> The vertex rounding radius. |
function triangle_aas2sss | ( | v | ) |
Compute the side lengths of a triangle given a side, one adjacent and the opposite angle.
v | <decimal-list-3> A list, [a1, a2, s1], a side length, one adjacent and the opposite angle. |
Each side length is opposite the corresponding vertex.
Object example
No verification is performed to ensure that the given sides specify a valid triangle. See Wikipedia for more information.
function triangle_asa2sss | ( | v | ) |
Compute the side lengths of a triangle given a side and two adjacent angles.
v | <decimal-list-3> A list, [a1, s3, a2], the side length and two adjacent angles. |
Each side length is opposite the corresponding vertex.
Object example
No verification is performed to ensure that the given sides specify a valid triangle. See Wikipedia for more information.
function triangle_centroid | ( | c | , |
d | = 2 |
||
) |
Compute the centroid of a triangle.
c | <coords-3d | coords-2d> A list of 3d or 2d vertex coordinates [v1, v2, v3]. |
d | <integer> The number of dimensions [2:3]. |
When d
is assigned 0, d
is set to the minimun number of coordinates of the vertices in c
.
See Wikipedia for more information.
function triangle_circumcenter | ( | c | , |
d | = 2 |
||
) |
Compute the coordinate of a triangle's circumcenter.
c | <coords-3d | coords-2d> A list of 3d or 2d vertex coordinates [v1, v2, v3]. |
d | <integer> The number of dimensions [2:3]. |
A circle that passes through all of the vertices of the triangle. The radius is the distance from the circumcenter to any of vertex. When d
is assigned 0, d
is set to the minimun number of coordinates of the vertices in c
. See Wikipedia for more information.
function triangle_ppp2sss | ( | c | ) |
Compute the side lengths of a triangle given its vertex coordinates.
c | <coords-3d | coords-2d> A list, [v1, v2, v3], the 3d or 2d vertex coordinates. |
Each side length is opposite the corresponding vertex.
Object example
No verification is performed to ensure that the given sides specify a valid triangle. See Wikipedia for more information.
function triangle_sas2sss | ( | v | ) |
Compute the side lengths of a triangle given two sides and the included angle.
v | <decimal-list-3> A list, [s1, a3, s2], the side lengths and the included angle. |
Each side length is opposite the corresponding vertex.
Object example
No verification is performed to ensure that the given sides specify a valid triangle. See Wikipedia for more information.