omdl
v0.6.1
OpenSCAD Mechanical Design Library
|
Triangle mathematical functions. More...
Files | |
file | math_triangle.scad |
Triangle solutions mathematical functions. | |
Functions | |
function | triangle_sss2lp (s1, s2, s3, cw=true) |
Compute the vertex coordinates of a triangle given its side lengths. More... | |
function | triangle_ls2lp (v, cw=true) |
Compute the vertex coordinates of a triangle given its side lengths. More... | |
function | triangle_ppp2ls (v1, v2, v3) |
Compute the side lengths of a triangle given its vertex coordinates. More... | |
function | triangle_lp2ls (v) |
Compute the side lengths of a triangle given its vertex coordinates. More... | |
function | triangle_area_ppp (v1, v2, v3, s=false) |
Compute the signed area of a triangle given its vertex coordinates. More... | |
function | triangle_area_lp (v, s=false) |
Compute the signed area of a triangle given its vertex coordinates. More... | |
function | triangle_centroid_ppp (v1, v2, v3) |
Compute the centroid (geometric center) of a triangle. More... | |
function | triangle_centroid_lp (v) |
Compute the centroid (geometric center) of a triangle. More... | |
function | triangle_incenter_ppp (v1, v2, v3) |
Compute the coordinate for the triangle's incircle. More... | |
function | triangle_incenter_lp (v) |
Compute the coordinate for the triangle's incircle. More... | |
function | triangle_inradius_ppp (v1, v2, v3) |
Compute the inradius of a triangle's incircle. More... | |
function | triangle_inradius_lp (v) |
Compute the inradius of a triangle's incircle. More... | |
function | triangle_is_cw_ppp (v1, v2, v3) |
Test the vertex ordering, or orientation, of a triangle. More... | |
function | triangle_is_cw_lp (v) |
Test the vertex ordering, or orientation, of a triangle. More... | |
function | triangle_is_pit_ppp (v1, v2, v3, t) |
Test if a point is inside a triangle in a Euclidean 2d-space using Barycentric. More... | |
function | triangle_is_pit_lp (v, t) |
Test if a point is inside a triangle in a Euclidean 2d-space using Barycentric. More... | |
Triangle mathematical functions.
See Wikipedia for more information.
function triangle_area_lp | ( | v | , |
s | = false |
||
) |
Compute the signed area of a triangle given its vertex coordinates.
v | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
s | <boolean> Return the vertex ordering sign. |
function triangle_area_ppp | ( | v1 | , |
v2 | , | ||
v3 | , | ||
s | = false |
||
) |
Compute the signed area of a triangle given its vertex coordinates.
v1 | <point-2d> A vertex coordinate [x, y] for vertex 1. |
v2 | <point-2d> A vertex coordinate [x, y] for vertex 2. |
v3 | <point-2d> A vertex coordinate [x, y] for vertex 3. |
s | <boolean> Return the vertex ordering sign. |
function triangle_centroid_lp | ( | v | ) |
Compute the centroid (geometric center) of a triangle.
v | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
function triangle_centroid_ppp | ( | v1 | , |
v2 | , | ||
v3 | |||
) |
Compute the centroid (geometric center) of a triangle.
v1 | <point-2d> A vertex coordinate [x, y] for vertex 1. |
v2 | <point-2d> A vertex coordinate [x, y] for vertex 2. |
v3 | <point-2d> A vertex coordinate [x, y] for vertex 3. |
function triangle_incenter_lp | ( | v | ) |
Compute the coordinate for the triangle's incircle.
v | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
The interior point for which distances to the sides of the triangle are equal.
function triangle_incenter_ppp | ( | v1 | , |
v2 | , | ||
v3 | |||
) |
Compute the coordinate for the triangle's incircle.
v1 | <point-2d> A vertex coordinate [x, y] for vertex 1. |
v2 | <point-2d> A vertex coordinate [x, y] for vertex 2. |
v3 | <point-2d> A vertex coordinate [x, y] for vertex 3. |
The interior point for which distances to the sides of the triangle are equal.
function triangle_inradius_lp | ( | v | ) |
Compute the inradius of a triangle's incircle.
v | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
function triangle_inradius_ppp | ( | v1 | , |
v2 | , | ||
v3 | |||
) |
Compute the inradius of a triangle's incircle.
v1 | <point-2d> A vertex coordinate [x, y] for vertex 1. |
v2 | <point-2d> A vertex coordinate [x, y] for vertex 2. |
v3 | <point-2d> A vertex coordinate [x, y] for vertex 3. |
function triangle_is_cw_lp | ( | v | ) |
Test the vertex ordering, or orientation, of a triangle.
v | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
function triangle_is_cw_ppp | ( | v1 | , |
v2 | , | ||
v3 | |||
) |
Test the vertex ordering, or orientation, of a triangle.
v1 | <point-2d> A vertex coordinate [x, y] for vertex 1. |
v2 | <point-2d> A vertex coordinate [x, y] for vertex 2. |
v3 | <point-2d> A vertex coordinate [x, y] for vertex 3. |
function triangle_is_pit_lp | ( | v | , |
t | |||
) |
Test if a point is inside a triangle in a Euclidean 2d-space using Barycentric.
v | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
t | <point-2d> A test point coordinate [x, y]. |
function triangle_is_pit_ppp | ( | v1 | , |
v2 | , | ||
v3 | , | ||
t | |||
) |
Test if a point is inside a triangle in a Euclidean 2d-space using Barycentric.
v1 | <point-2d> A vertex coordinate [x, y] for vertex 1. |
v2 | <point-2d> A vertex coordinate [x, y] for vertex 2. |
v3 | <point-2d> A vertex coordinate [x, y] for vertex 3. |
t | <point-2d> A test point coordinate [x, y]. |
See Wikipedia for more information.
function triangle_lp2ls | ( | v | ) |
Compute the side lengths of a triangle given its vertex coordinates.
v | <coords-2d> A list of vertex coordinates [v1, v2, v3]. |
function triangle_ls2lp | ( | v | , |
cw | = true |
||
) |
Compute the vertex coordinates of a triangle given its side lengths.
v | <decimal-list-3> The list of side lengths [s1, s2, s3]. |
cw | <boolean> Order vertices clockwise. |
Geometry requires that s1
+ s2
is greater then s3
. A coordinates will be 'nan' when specified triangle does not exists.
v1
at the origin. Side length s1
is measured along the positive x-axis. function triangle_ppp2ls | ( | v1 | , |
v2 | , | ||
v3 | |||
) |
Compute the side lengths of a triangle given its vertex coordinates.
v1 | <point-2d> A vertex coordinate [x, y] for vertex 1. |
v2 | <point-2d> A vertex coordinate [x, y] for vertex 2. |
v3 | <point-2d> A vertex coordinate [x, y] for vertex 3. |
function triangle_sss2lp | ( | s1 | , |
s2 | , | ||
s3 | , | ||
cw | = true |
||
) |
Compute the vertex coordinates of a triangle given its side lengths.
s1 | <decimal> The length of the side 1. |
s2 | <decimal> The length of the side 2. |
s3 | <decimal> The length of the side 3. |
cw | <boolean> Order vertices clockwise. |
Geometry requires that s1
+ s2
is greater then s3
. A coordinates will be 'nan' when specified triangle does not exists.
v1
at the origin. Side length s1
is measured along the positive x-axis.