function rndc() = rands(0, 1, 3) ;
Monday, July 31, 2017
Random RGB Color
Generates a random rgb color value to be used by color();
Saturday, July 29, 2017
Radius Of An Arc By Chord And Height
function Radius_Of_An_Arc_By_Chord_And_Height(C,h)=h/2+(C*C)/(8*h);
Related: Circle defined by three points (2d)
Thursday, July 27, 2017
Area Of A Circle Segment By Angle
function Area_Of_A_Circle_Segment_By_Angle(r,c)=
(r*r)/2*(PI/180*c-sin(c));
Tuesday, July 25, 2017
Area Of A Circle Segment By Height
function Area_Of_A_Circle_Segment_By_Height(r,h)=
(r*r)*acos((r-h)/r)*((2*PI)/360)-(r-h)*sqrt((2*r*h)-(h*h));
Sunday, July 23, 2017
Arc Length By Angle
function Arc_Length_By_Angle(radius,central_angle)=
2*PI*radius*(central_angle/360);
Friday, July 21, 2017
Area Circle Sector By Arc Length
function Area_Circle_Sector_By_Arc_Length(radius,length)=
(radius*length)/2;
Wednesday, July 19, 2017
Perimeter Of A Circle Sector By Angle
function Perimeter_Of_A_Circle_Sector_By_Angle (radius,central_angle)=
central_angle<360?
2*PI*radius*(central_angle/360)+(2*r)
:2*PI*radius*(central_angle/360);
Monday, July 17, 2017
Saturday, July 15, 2017
Friday, July 14, 2017
List Lerp
Linear interpolation over the items in a list
list=[[1,6],[3,5],[5,3],[1,2],[0,6]];
for(x=[0.01:0.05:4]){
echo(listlerp (list,x));
translate(listlerp (list,x))sphere(0.1);}
function listlerp (l,I)=
let(
f=len(l)-1,start=max(0,min(f,floor(I))),
end=max(0,min(f,ceil(I))),bias=I%1)
(l[end]* bias + l[start] * (1 - bias));
Thursday, July 13, 2017
Wednesday, July 12, 2017
Tuesday, July 11, 2017
Monday, July 10, 2017
Sunday, July 9, 2017
Saturday, July 8, 2017
Mystic Scribbles
Generate a page of random nonsense scribbles in the style of mystic manuscript.
for (rows=[0:20])
{My_poly_line=make_points(120- round(rnd(20)));
translate([rnd(20),rows*27])polyline(My_poly_line);
}
module sline(p1, p2 ,width=0.6,s=12) {
if(abs(p1.x-p2.x)>abs(p1.y-p2.y)){
for(i=[-1/s:1/s:1+1/s])
line(xlerp(p1,p2,i),xlerp(p1,p2,i+1/s),width);}
else{for(i=[0:1/s:1-1/s])
line(ylerp(p1,p2,i),ylerp(p1,p2,i+1/s),width);}}
module line(p1, p2 ,width=0.3) {
hull() {
translate(p1) rotate(45)scale([3,0.1]) circle(width);
translate(p2) rotate(45)scale([3,0.1]) circle(width); }}
module polyline(p) {for(i=[0:max(0,len(p)-2)])
if(round(rnd(0.53))==0)sline(p[i],p[i+1]);}
function smooth_curve(a) =
let (b = clamp(a))(b * b * (3 - 2 * b));
function clamp(a, b = 0, c = 1) = min(max(a, b), c);
function lerp(start, end, bias) = (end * bias + start * (1 - bias));
function xlerp(start, end, i) =
[lerp(start.x,end.x,smooth_curve(i)),lerp(start.y,end.y,i)];
function ylerp(start, end, i) =
[lerp(start.x,end.x,i),lerp(start.y,end.y,smooth_curve(i))];
function make_points(j=10,l1=[-30,-10],l2=[30,10])=
([for(i=[1:j])[
rnd(l1.x,l2.x)/4+i*4,
rnd(l1.y,l2.y)]]);
function rnd(a = 1, b = 0, s = []) =
s == [] ?
(rands(min(a, b), max( a, b), 1)[0])
:
(rands(min(a, b), max(a, b), 1, s)[0])
;
Friday, July 7, 2017
Thursday, July 6, 2017
Volume Of A Prism By Sides Height
function Volume_Of_A_Prism_By_Sides_Height(A,B,C,H)=
let(s=(a+b+c)/2) sqrt(abs(s*(s-a)*(s-b)*(s-c)))*H;
Wednesday, July 5, 2017
Tuesday, July 4, 2017
Monday, July 3, 2017
Area Of A Prism By Sides Height
function Area_Of_A_Prism_By_Sides_Height(A,B,C,H)=let(s=(a+b+c)/2)
2*sqrt(abs(s*(s-a)*(s-b)*(s-c)))+A*H+B*H+C*H;
Sunday, July 2, 2017
Area Of A Pyramid By Sides And Height
function Area_Of_A_Pyramid_By_Sides_And_Height(A,B,h )=
A*B+ 2*( (1/2)* A* (sqrt(h*h+(B/2)*(B/2))) )
+ 2*( (1/2)* B* (sqrt(h*h+(A/2)*(A/2))) );
Saturday, July 1, 2017
Area Of A Cone By Radius And Height
function Area_Of_A_Cone_By_Radius_And_Height(r,h )=
PI*r*r+ PI*r*sqrt(r*r+h*h);
Subscribe to:
Posts (Atom)