#include "math.inc" #macro Shape_Slice_Plane_2P_1V(point1, point2, clip_direct) #local p1 = point1 + <0,0,0>; #local p2 = point2 + <0,0,0>; #local clip_v = vnormalize(clip_direct + <0,0,0>); #local direct_v1 = vnormalize(p2 - p1); #if(vdot(direct_v1, clip_v) = 1) #error "Shape_Slice_Plane_2P_1V error: Can't decide plane" #end #local norm = -vnormalize(clip_v - direct_v1*vdot(direct_v1,clip_v)); #local d = vdot(norm, p1); plane{ norm, d } #end //polygon to circle #macro Shape_Polygon_To_Circle_Blending(_polygon_n, _side_face, _polygon_circumscribed_radius, _circle_radius, _height) #local n = int(_polygon_n); #if(n < 3) #error "" #end #local front_v = VPerp_Adjust(_side_face, z); #if(vdot(front_v, x) >= 0) #local face_ang = acos(vdot(-y, front_v)); #else #local face_ang = -acos(vdot(-y, front_v)); #end #local polyg_ext_ang = 2*pi/n; #local polyg_outer_r = _polygon_circumscribed_radius; #local polyg_inner_r = polyg_outer_r*cos(polyg_ext_ang/2); #local cycle_r = _circle_radius; #local h = _height; #if(polyg_outer_r < 0 | cycle_r < 0 | h <= 0) #error "error: each side length must be positive" #end #local multi = 1000; #local poly_obj = polynomial{ 4, xyz(0,2,2): multi*1, xyz(2,0,1): multi*2*h, xyz(1,0,2): multi*2*(polyg_inner_r-cycle_r), xyz(2,0,0): multi*(-h*h), xyz(0,0,2): multi*(-pow(cycle_r - polyg_inner_r, 2)), xyz(1,0,1): multi*2*h*(-2*polyg_inner_r + cycle_r), xyz(1,0,0): multi*2*h*h*polyg_inner_r, xyz(0,0,1): multi*2*h*polyg_inner_r*(polyg_inner_r - cycle_r), xyz(0,0,0): multi*(-pow(polyg_inner_r*h, 2)) sturm } #local mockup1 = difference{ cylinder{ <0,0,0.0>,<0,0,h>, max(polyg_outer_r, cycle_r) } #for(i, 0, n-1) object{ poly_obj inverse rotate <0, 0, -90 + degrees(polyg_ext_ang*i)> } object{ Shape_Slice_Plane_2P_1V(,,x) rotate <0, 0, -90 + degrees(polyg_ext_ang*i)> } #end } object{ mockup1 rotate <0, 0, degrees(face_ang)> } #end