This Script adds a Function for creating a Gear with Triangle shaped Teeth to Physion.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | //Triangle_Tooth_Gear.script
function Triangle_Tooth_Gear(x,y,radius,tooth_size,tooth_count){
phi=0;
phi_plus=360.0/tooth_count;
phi_plus=(2*3.1415926*phi_plus)/360;
tooth=0;
radius2=radius-tooth_size;
var gear = new QPolygonF();
for(tooth=0;tooth<tooth_count;tooth++){
px=radius*Math.cos(phi);
py=radius*Math.sin(phi);
gear.append(new QPointF(x+px,y+py));
px=radius2*Math.cos(phi+(phi_plus/2));
py=radius2*Math.sin(phi+(phi_plus/2));
gear.append(new QPointF(x+px,y+py));
phi=phi+phi_plus;
}
return world.createPolygon(gear);
}
|
A simple addon for Physion 2D Physics Simulation Software (http://physion.net/).
Adds a Function to create a Gear with Triangle shaped Teeth.
P.S.: I made this Script mainly for practising JavaScript and Geometric Calculations, but maybe it could be interresting for someone else, so i decided to post it here.
Tags: addon