PreviousHomeNext

Rounded objects - Deform

A rounded object is defined by the (x,y,z) functions of the components. By making these functions themselves functions of position, we can be deform the object in interesting ways. In the following examples these deformation is a functions of x. In the illustration a simple square sectioned block is deformed by a variable amount along the x-axis. In most of these examples I have used a sine function for simplicity and familiarity but it could easily be a spline or polynomial.

Shear deformation

Fig 1: shear deformation

These examples can be regenerated by running the code below with the appropiate lines un-commented

45 deg shear deformationFig 2: Shear deformation with surfaces at an angle to the direction of shear.
scale deformationFig 3: Scale deformation. Note that the radius of the corners of the stretched faces is also stretched.
45 deg deformationFig 4: Scale deformation with surfaces at an angle.
deform back and front 1

Fig 5: Different deformation of the back and front surfaces.

Shear and scale deformations can be combined so that the shape of the surfaces can be defined.

deform back and front 2Fig 6: Different deformation of the back and front surfaces.
Twisting deformationFig 7: Twisting deformation
Tilting deformationFig 8: Tilting deformation
deform1Fig 9: Combination of deformations 1
deform2Fig 10: Combination of deformations 2
deform3Fig 11: Combination of deformations 3
// This work is licensed under the Creative Commons Attribution 3.0 Unported License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/
// or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View,
// California, 94041, USA.

// Rounded objects: Illustration of deformation

// Vers: 1.00
// Date: 24 Nov 2016
// Auth: John Greenwood

#version 3.7 ;
global_settings {assumed_gamma 1.0 }
#include "Rounded_Objects.inc"

camera {location <-0,20,-60> angle 8 look_at <0,0,0> }
light_source {<-20,20,-20> colour rgb<1,1,1>}
background { color rgb<0.2, 0.4, 0.8> }
/*
//DeformSide-------------------------------------------------------------------------------------
#declare Side_y = function(x){}
#declare Side_z = function(x){0}
#declare Scale_y = function(x){1}
#declare Scale_z = function(x){1}
#declare Rotate_yz = function(x){ (0)}
#declare Tilt_y = function(x){0}
#declare Tilt_z = function(x){0}

//DeformScale-------------------------------------------------------------------------------------
#declare Side_y = function(x){0}
#declare Side_z = function(x){0}
#declare Scale_y = function(x){1+.3*sin(3*x)}
#declare Scale_z = function(x){1}
#declare Rotate_yz = function(x){ (0)}
#declare Tilt_y = function(x){0}
#declare Tilt_z = function(x){0}

//DeformRotate-------------------------------------------------------------------------------------
#declare Side_y = function(x){0}
#declare Side_z = function(x){0}
#declare Scale_y = function(x){1}
#declare Scale_z = function(x){1}
#declare Rotate_yz = function(x){pow(.3*x,3)}
#declare Tilt_y = function(x){0}
#declare Tilt_z = function(x){0}

//DeformTilt-------------------------------------------------------------------------------------
#declare Side_y = function(x){0}
#declare Side_z = function(x){0}
#declare Scale_y = function(x){1+.1*sin(10*x)}
#declare Scale_z = function(x){1+.1*sin(10*x)}
#declare Rotate_yz = function(x){0}
#declare Tilt_y = function(x){.2*cos(x)}
#declare Tilt_z = function(x){0}
//DeformBackFront1 p=-1 -------------------------------------------------------------------------------------
#local Front = function(x){1.5+ .6*sin(3*x)}
#local Back = function(x){1.2+.3*x}
#declare Side_y = function(x){0}
#declare Side_z = function(x){Back(x)-Front(x) }
#declare Scale_y = function(x){1}
#declare Scale_z = function(x){-.66*(Back(x)+Front(x))} //I have not worked out where the 0.66 comes from!
#declare Rotate_yz = function(x){ (0)}
#declare Tilt_y = function(x){0}
#declare Tilt_z = function(x){0}
*/
//DeformBackFront2 p=1 -------------------------------------------------------------------------------------

#local Front = function(x){1.5+ .6*sin(2*x)}
#local Back = function(x){1.2+ .6*sin(x)}
#declare Side_y = function(x){0}
#declare Side_z = function(x){Back(x)-Front(x) }
#declare Scale_y = function(x){1}
#declare Scale_z = function(x){-.66*(Back(x)+Front(x))}
#declare Rotate_yz = function(x){ (0)}
#declare Tilt_y = function(x){0}
#declare Tilt_z = function(x){0}
/*
//Deform1 -------------------------------------------------------------------------------------

#local Front = function(x){1.5+ .6*sin(3*x)}
#local Back = function(x){1.2+ .6*sin(x)}
#declare Side_y = function(x){0}
#declare Side_z = function(x){Back(x)-Front(x) }
#declare Scale_y = function(x){1}
#declare Scale_z = function(x){-.66*(Back(x)+Front(x))}
#declare Rotate_yz = function(x){ .2*x}
#declare Tilt_y = function(x){0}
#declare Tilt_z = function(x){0}



//Deform2-------------------------------------------------------------------------------------
#declare Side_y = function(x){ .4*sin(1*x)}
#declare Side_z = function(x){ .4*cos(1*x)}
#declare Scale_y = function(x){ 1+.1*sin(2*x)}
#declare Scale_z = function(x){ 1+ .2*cos(3*x)}
#declare Rotate_yz = function(x){ (0)}
#declare Tilt_y = function(x){0}
#declare Tilt_z = function(x){0}

//Deform3----------------------------------------------------------------------------------------
#declare Side_y = function(x){.0}
#declare Side_z = function(x){0}
#declare Scale_y = function(x){1+.1*sin(10*x)}
#declare Scale_z = function(x){1+.1*sin(10*x)}
#declare Rotate_yz = function(x){ .2*x}
#declare Tilt_y = function(x){.2*sin(x)}
#declare Tilt_z = function(x){ .2*cos(x)}
//------------------------------------------------------------------------------------------

*/
#local Def_y = function(x,y,z){((y+Side_y(x))/Scale_y(x))*cos(Rotate_yz(x)) -((z+Side_z(x))/Scale_z(x))*sin(Rotate_yz(x))}
#local Def_z = function(x,y,z){((y+Side_y(x))/Scale_y(x))*sin(Rotate_yz(x)) +((z+Side_z(x))/Scale_z(x))*cos(Rotate_yz(x))}
#local Tiltx = function(x,y,z){(x*cos(Tilt_y(x))-y*sin(Tilt_y(x)))*cos(Tilt_z(x))-z*sin(Tilt_z(x)) }
#local Tilty = function(x,y,z){x*sin(Tilt_y(x))+y*cos(Tilt_y(x)) }
#local Tiltz = function(x,y,z){(x*sin(Tilt_z(x))+z*cos(Tilt_z(x)))*sin(Tilt_z(x))+z*cos(Tilt_z(x)) }

#declare p = 1; // change this to change the shape of the corner. 0.6 gives very close to circular
#declare r = 1; // radius when the corner is circular and surfaces are perpendicular
/*
#declare R_Object1 =
function(x,y,z){
R_Intersection(
+R_function(p,(x +(4)) /-r)
+R_function(p,(x -(4)) /+r)
+R_function(p,(z +(1.5)) /-r)
+R_function(p,(z -(1.5)) /+r)
+R_function(p,(y +(1.5)) /-r)
+R_function(p,(y -(1.5)) /+r)
)
}

#local R_Object2 =
function(x,y,z){ R_Object1(x,Def_y(x,y,z),Def_z(x,y,z)) }



isosurface {
function {
// start of rounded object ****************************************

R_Object2(Tiltx(x,y,z),Tilty(x,y,z),Tiltz(x,y,z))

// end of rounded object **************************

}
threshold 1
max_gradient 20
contained_by { box {<-4.2,-3.2, -4.2>, <4.2,3.2,4.2>} }
texture {pigment {color rgb < 1, 0.9, 0.65>}}

}