Title: New shapes in primitives.cpp
Post by: DarkBeam on March 05, 2015, 11:33:21 AM
I haven't tested those routines. :embarrass: Torus (customized); :D double PrimitiveTorus(CVector3 point, CVector3 center, double radius1, double radius2, boolean Squarry1, boolean Squarry2) { CVector3 ptc = point - center; double cyl = 0; if (Squarry1==true) { cyl = max(ptc.x,ptc.y);} else { cyl = hypot(ptc.x,ptc.y);} double distance = -radius2; if (Squarry2==true) { distance += max(radius1-cyl ,ptc.z);} else { distance += hypot(radius1-cyl ,ptc.z);} return distance; } Cylinder (customized); :D double PrimitiveCylinder(CVector3 point, CVector3 center, double barrel, double cone, double radius, double height) { CVector3 ptc = point - center; double cyl = hypot(ptc.x,ptc.y); cyl += (barrel*ptc.z + cone)*ptc.z/(1.+fabs(barrel)+fabs(cone)); double distance = max(cyl - radius , fabs(ptc.z) - height); return distance; }
Title: Re: New shapes in primitives.cpp
Post by: DarkBeam on March 05, 2015, 12:20:54 PM
Cylindrical wave :D double PrimitiveSimpleWater(CVector3 point, double height, double amplitude1, double amplitude2, double rotation, int nangwave, double animSpeed, int frame) { CVector3 plane(0,0,-1); CVector3 centre(0,0,height); plane.Normalize(); CVector3 ptc = point - center; double planeDistance = plane.Dot( ptc ); if(planeDistance < max(amplitude1,amplitude2) * 10.0) { CRotationMatrix rotMatrix; rotMatrix.RotateZ(rotation/180*M_PI); point = rotMatrix.RotateVector(point);
double phase = animSpeed * frame; double dorig = hypot(ptc.x,ptc.y); double waveX = sin(phase + dorig ); // interesting to add another phase and try to multiply dorig by something double waveY = sin(phase + nangwave*atan2(ptc.y,ptc.x)); // interesting to add another phase waveY = waveY*(1.-1./(1.+dorig)); // less perturbed in the center planeDistance += amplitude1*waveX + amplitude2*waveY; // interesting to add another wave (interference effect) ... etc }
return planeDistance; }
Title: Re: New shapes in primitives.cpp
Post by: DarkBeam on March 05, 2015, 12:48:13 PM
Supershape (to be converted!)
http://www.fractalforums.com/general-discussion-b77/supershape-as-an-isosurface/msg80070/#msg80070
Knot (to be converted!) - only Knighty's routine, more general
http://www.fractalforums.com/index.php?topic=10072.msg40636#msg40636
|