101 b = (cw ==
true) ? [360:-(360/n):1] : [0:(360/n):359]
105 let( v = [s*cos(a+o), s*sin(a+o)] + c )
106 is_undef(vr) ? v : v - vr/cos(180/n) *
unit_l(v)
171 s = (tp[a] > ip[a]) ? +1 : -1,
178 [
for (i=is_list(r) ? r : [r]) (i*(tp[a]-ip[a])+ip[a])]
187 [
for (i=[ip[a] : s*sx : tp[a]]) i]
196 co = ( abs(tp[a]-ip[a]) - sx*floor(abs(tp[a]-ip[a])/sx) )/2
198 [ip[a],
for (i=[ip[a] + s*co : s*sx : tp[a]]) i, tp[a]]
201 : [
for (i=[0:fn]) (i*(tp[a]-ip[a])/fn+ip[a])]
250 va1 =
is_number(v1) ? [cos(v1), sin(v1)] : v1,
251 va2 =
is_number(v2) ? [cos(v2), sin(v2)] : v2,
258 vap = (vas == 0) ? 360 : vas,
261 sas = (((cw ==
true) ? 0 : 360) - vap)/naf
265 let (aa = iap + as * sas)
266 c + r * [cos(aa), sin(aa)]
313 va3 = (va1 == va2) ? va2+360 : va2,
319 as = (va3 > va1) ? [af:-1:0] : [0:af],
326 let (pa = ((af-i)*va1 + i*va3) / af)
327 c + [rx*cos(pa), ry*sin(pa)]
330 (cw ==
true) ? pp :
reverse(pp);
370 p2 = o + (is_undef(h) ? l*[cos(a), sin(a)] : h*[cos(a), 1]),
375 pp = [p4, p1, p2, p3]
377 (cw ==
true) ? pp :
reverse(pp);
428 ) =
is_defined(r) ? pow(r, 2) * n * sin(360/n) / 2
459 for (k = pm) let (n = len(k))
460 for (i=[0 : n-1]) let (j = (i == 0) ? n-1 : i-1)
501 for (k = pm) let (n = len(k))
502 for (i=[0 : n-1]) let (j = (i == 0) ? n-1 : i-1)
503 (c[k[j]][0] + c[k[i]][0]) * (c[k[i]][1] - c[k[j]][1])
508 (s ==
false) ? abs(sa) : sa;
546 ac = [abs(nv[0]), abs(nv[1]), abs(nv[2])],
548 ai = (am == ac[2]) ? 2 : (am == ac[1]) ? 1 : 0,
551 for (k = pm) let (m = len(k))
553 c[k[i%m]][(ai+1)%3] * (c[k[(i+1)%m]][(ai+2)%3] - c[k[(i-1)%m]][(ai+2)%3])
593 for (k = pm) let (n = len(k))
597 j = (i == 0) ? n-1 : i-1,
607 [(xc + xn) * cd, (yc + yn) * cd]
663 for (k = pm) let (n = len(k))
667 j = (i == 0) ? n-1 : i-1,
670 (c[k[j]][1] <= t[1]) && (c[k[i]][1] > t[1])
674 (c[k[j]][1] > t[1]) && (c[k[i]][1] <= t[1])
743 ) = is_undef(c) ? undef
752 for (k = pm) let (n = len(k))
754 sign(
cross_ll([c[k[i]], c[k[(i+1)%n]]], [c[k[(i+1)%n]], c[k[(i+2)%n]]]))
823 for (k = pm) let (n = len(k))
827 j = (i == 0) ? n-1 : i-1
829 angle_ll([t, c[k[i]]], [t, c[k[j]]])
877 pn = len([for (
pi = pm) for (ci =
pi) 1]),
880 zr = (center == true) ? [-h/2, h/2] : [0, h],
884 pp = [for (zi = zr) for (
pi = pm) for (ci =
pi) concat(c[ci] - po, zi)],
887 [for (
pi = pm) for (ci =
pi) ci],
888 [for (
pi = pm) for (cn = [len(
pi)-1 : -1 : 0])
pi[cn] + pn],
889 for (
pi = pm) for (ci =
pi)
891 ? [ci, ci+pn, (ci+1)%pn+pn, (ci+1)%pn]
892 : [ci, (ci+1)%pn, (ci+1)%pn+pn, ci+pn]
951 va1 =
is_number(v1) ? [cos(v1), sin(v1)] : v1,
952 va2 =
is_number(v2) ? [cos(v2), sin(v2)] : v2,
964 vim = (m == 1) ? sqrt( pow(
distance_pp(c, tcc),2) - pow(r,2) ) : r,
967 tc1 = c + vim*
unit_l(va1),
968 tc2 = c + vim*
unit_l(va2),
971 vpl = (m == 1) ?
polygon_arc_p(r=r, c=tcc, v1=[tcc, tc1], v2=[tcc, tc2], fn=fn, cw=true)
972 : (m == 2) ?
polygon_arc_p(r=r, c=tcc, v1=[tcc, tc1], v2=[tcc, tc2], fn=fn, cw=false)
976 pp = concat([tc1], vpl, [tc2])
978 (cw == true) ? pp :
reverse(pp);
1075 cp = (cw == true) ? c :
reverse(c),
1083 for ( i = [0 : len(avl)-1] )
1106 : (rm == 1 || rm == 2) ?
1116 : (rm == 1 || rm == 2) ?
1131 tc1 = (rm == 0 || rm > 10) ?
origin2d
1132 : (rm == 3 || rm == 7 || rm == 9) ?
1133 vc + vim *
unit_l([vp, vc])
1134 : vc + vim *
unit_l([vc, vp]),
1136 tc2 = (rm == 0 || rm > 10) ?
origin2d
1137 : (rm == 4 || rm == 8 || rm == 10) ?
1138 vc + vim *
unit_l([vn, vc])
1139 : vc + vim *
unit_l([vc, vn]),
1142 vpl = (rm == 0 || rm > 10) ? [vc]
1144 polygon_arc_p(r=rr, c=tcc, v1=[tcc, tc1], v2=[tcc, tc2], fn=fn, cw=!ras)
1145 : (rm == 2 || rm == 3 || rm == 4) ?
1146 polygon_arc_p(r=rr, c=tcc, v1=[tcc, tc1], v2=[tcc, tc2], fn=fn, cw=ras)
1147 : (rm == 6 || rm == 7 || rm == 8) ?
1148 polygon_arc_p(r=rr, c=vc, v1=[vc, tc1], v2=[vc, tc2], fn=fn, cw=!ras)
1157 (cw == true) ? pp :
reverse(pp);
1273 arc = is_undef( arv ) ? 0 : is_list( arv ) ? len( arv ) : 1,
1281 p = (opr == "mxy" || opr == "move_xy" ) && (arc == 2) ? [a1, a2]
1283 : (opr == "mx" || opr == "move_x" ) && (arc == 1) ? [a1, i.y]
1284 : (opr == "my" || opr == "move_y" ) && (arc == 1) ? [i.x, a1]
1286 : (opr == "dxy" || opr == "delta_xy" ) && (arc == 2) ? i + [a1, a2]
1288 : (opr == "dx" || opr == "delta_x" ) && (arc == 1) ? i + [a1, 0]
1289 : (opr == "dy" || opr == "delta_y" ) && (arc == 1) ? i + [0, a1]
1291 : (opr == "dxa" || opr == "delta_xa" ) && (arc == 2) ? i + [a1, a1 * tan(a2)]
1292 : (opr == "dya" || opr == "delta_ya" ) && (arc == 2) ? i + [a1 / tan(a2), a1]
1294 : (opr == "dv" || opr == "delta_v" ) && (arc == 2) ?
line_tp(
line2d_new(m=a1, a=a2, p1=i) )
1296 : (opr == "apv" || opr == "arc_pv" ) && (arc == 3) ?
1299 v2 = is_list(a2) ? [a1, a2] : a2
1303 : (opr == "avv" || opr == "arc_vv" ) && (arc == 3) ?
1307 v2 = is_list(a2) ? [b1, a2] : a2
1313 str ( "ERROR at '", stp, "', num='", c, "', operation='", opr
1314 , "', argc='", arc, "', argv='", arv,"'" )
1319 cp = (lp > 2) ? p : [p],
1320 ni = (lp > 2) ?
last(p) : p
origin2d
<point-2d> The origin point coordinate in 2d Euclidean space.
x_axis2d_uv
<vector-2d> The unit vector of the positive x-axis in 2d Euclidean space.
y_axis2d_uv
<vector-2d> The unit vector of the positive y-axis in 2d Euclidean space.
pi
<decimal> The ratio of a circle's circumference to its diameter.
empty_lst
<list> A list with no values (the empty list).
function line_tp(l)
Return the terminal point of a line or vector.
function angle_ll(l1, l2, s=true)
Compute the angle between two lines or vectors in a 3d or 2d-space.
function line_ip(l)
Return the initial point of a line or vector.
function cross_ll(l1, l2)
Compute the cross product of two lines or vectors in a 3d or 2d-space.
function is_left_ppp(p1, p2, p3)
Test if a point is left, on, or right of an infinite line in a 2d-space.
function line2d_new(m=1, a=0, p1=origin2d, p2, v)
Construct a 2 dimensional directed line.
function unit_l(l)
Compute the normalized unit vector of a line or vector.
function interpolate2d_l_pp(p1, p2, x, y)
Linearly interpolate along a line established by two points in 2d.
function distance_pp(p1, p2)
Compute the distance between two points.
function unique(v)
Return a list of the unique elements of an iterable value.
function defined_e_or(v, i, d)
Return an element of an iterable when it exists or a default value otherwise.
function third(v)
Return the third element of an iterable value.
function last(v)
Return the last element of an iterable value.
function second(v)
Return the second element of an iterable value.
function first(v)
Return the first element of an iterable value.
function sequence_ns(v, n=1, s=1, w=false)
Return a list of all n-element sequential-subsets of an iterable value.
function tailn(v, n=1)
Return a list containing all but the first n elements of an iterable value.
function reverse(v)
Reverse the elements of an iterable value.
function all_len(v, l, c=0)
Test if all elements of an iterable value are iterable with a fixed length.
function almost_eq_nv(v1, v2, p=6)
Test to see if two numerical vectors are sufficiently equal.
function consts(l, v, u=false)
Create a list of constant or incrementing elements.
function merge_s(v, r=false)
Serially merge the elements of a list.
function sum(v, i1, i2)
Compute the sum of a list of numbers.
function defined_or(v, d)
Return given value, if defined, or a secondary value, if primary is not defined.
function is_scalar(v)
Test if a value is a single non-iterable value.
function is_defined(v)
Test if a value is defined.
function is_number(v)
Test if a value is a number.
function polygon_arc_p(r=1, c=origin2d, v1=x_axis2d_uv, v2=x_axis2d_uv, fn, cw=true)
Compute coordinates of an arc with constant radius between two vectors in 2D.
function polygon_regular_perimeter(n, r, a)
Compute the perimeter of an n-sided regular polygon in 2D.
function polygon3d_area(c, p, n)
Compute the area of a polygon in a Euclidean 3d-space.
function polygon_regular_area(n, r, a)
Compute the area of an n-sided regular polygon in 2D.
function polygon_winding(c, p, t)
Compute the winding number of a polygon about a point in a Euclidean 2d-space.
function polygon_trapezoid_p(b=1, h, l=1, a=90, o=origin2d, cw=true)
Compute the coordinates for a rounded trapezoid in 2D space.
function polygon_linear_extrude_pf(c, p, h=1, centroid=false, center=false)
Convert a polygon in 2D to a polyhedron by adding a height dimension.
function polygon_regular_p(n, r, a, c=origin2d, o=0, vr, cw=true)
Compute coordinates for an n-sided regular polygon in 2D.
function polygon_as_is_p_inside(c, p, t)
Test if a point is inside a polygon in a Euclidean 2d-space using angle summation.
function polygon_round_eve_all_p(c, vr=0, vrm=1, vfn, w=true, cw=true)
Compute coordinates that round all of the vertices between each adjacent edges in 2D.
function polygon_is_convex(c, p)
Test the convexity of a polygon in a Euclidean 2d-space.
function polygon_round_eve_p(r=1, m=1, c=origin2d, v1=x_axis2d_uv, v2=y_axis2d_uv, fn, cw=true)
Compute coordinates for a constant radius vertex round between two edge vectors in 2D.
function polygon_wn_is_p_inside(c, p, t)
Test if a point is inside a polygon in a Euclidean 2d-space using winding number.
function polygon_line_p(p1=origin2d, p2=x_axis2d_uv, l, x, y, r, fs, ft, fn=1)
Compute coordinates along a line in 2D.
function polygon_centroid(c, p)
Compute the center of mass of a polygon in a Euclidean 2d-space.
function polygon_turtle_p(s, i=origin2d, c=0)
Generate list of coordinate points from simple operation step notation.
function polygon_area(c, p, s=false)
Compute the signed area of a polygon in a Euclidean 2d-space.
function polygon_perimeter(c, p)
Calculate the perimeter length of a polygon in 2d.
function polygon_is_clockwise(c, p)
Test the vertex ordering of a polygon in a Euclidean 2d-space.
function polygon_elliptical_sector_p(r=1, c=origin2d, v1=x_axis2d_uv, v2=x_axis2d_uv, s=true, fn, cw=true)
Compute coordinates for an elliptical sector in 2D.
function triangle2d_inradius(c)
Compute the inradius of a triangle's incircle in 2D.
function triangle2d_excenter(c, v=1)
Compute the center coordinate of a triangle's excircle in 2D.
function triangle2d_exradius(c, v=1)
Compute the exradius of a triangle's excircle in 2D.
function triangle2d_incenter(c)
Compute the center coordinate of a triangle's incircle in 2D.
function get_fn(r)
Return facets number for the given arc radius.