Tutorials | (back to the list of tutorials) |
Panelization Example3![]()
![]()
![]()
![]()
import processing.opengl.*;
import igeo.*;
size(480,360,IG.GL);
IG.open("surface4.3dm");
ISurface[] surfaces = IG.surfaces();
for(ISurface surf : surfaces){
int unum = 20, vnum=20;
double uinc = 1.0/unum, vinc = 1.0/vnum;
for(int i=0; i < unum; i++){
for(int j=0; j < vnum; j++){
if( (i+j)%2== 0 ){
IVec[][] pts = new IVec[2][4];
pts[0][0] = surf.pt( i*uinc, j*vinc );
pts[1][0] = surf.pt( (i+1)*uinc, j*vinc );
pts[0][1] = surf.pt( i*uinc, (j+2.0/3)*vinc );
pts[1][1] = surf.pt( (i+1)*uinc, (j+2.0/3)*vinc );
pts[0][2] = surf.pt( i*uinc, (j+4.0/3)*vinc );
pts[1][2] = surf.pt( (i+1)*uinc, (j+4.0/3)*vinc );
pts[0][3] = surf.pt( i*uinc, (j+2)*vinc );
pts[1][3] = surf.pt( (i+1)*uinc, (j+2)*vinc );
IVec rotAxis = pts[1][3].dif(pts[1][2]);
// rotating around the center pts[1][2] and the axis rotAxis
pts[0][2].rot(pts[1][2],rotAxis,-PI/2);
// rotating around the center pts[1][3] and the axis rotAxis
pts[0][3].rot(pts[1][3],rotAxis,-PI/2);
new ISurface(pts, 1, 3);
}
}
}
surf.del();
}
Then the rotation angle is randomized.
![]()
![]()
![]()
![]()
import processing.opengl.*;
import igeo.*;
size(480,360,IG.GL);
IG.open("surface4.3dm");
ISurface[] surfaces = IG.surfaces();
for(ISurface surf : surfaces){
int unum = 20, vnum=20;
double uinc = 1.0/unum, vinc = 1.0/vnum;
for(int i=0; i < unum; i++){
double maxAngle = IRandom.get(0, PI*2/3);
for(int j=0; j < vnum; j++){
if( (i+j)%2== 0 ){
IVec[][] pts = new IVec[2][4];
pts[0][0] = surf.pt( i*uinc, j*vinc );
pts[1][0] = surf.pt( (i+1)*uinc, j*vinc );
pts[0][1] = surf.pt( i*uinc, (j+2.0/3)*vinc );
pts[1][1] = surf.pt( (i+1)*uinc, (j+2.0/3)*vinc );
pts[0][2] = surf.pt( i*uinc, (j+4.0/3)*vinc );
pts[1][2] = surf.pt( (i+1)*uinc, (j+4.0/3)*vinc );
pts[0][3] = surf.pt( i*uinc, (j+2)*vinc );
pts[1][3] = surf.pt( (i+1)*uinc, (j+2)*vinc );
IVec rotAxis = pts[1][3].dif(pts[1][2]);
// rotating around the center pts[1][2] and the axis rotAxis
pts[0][2].rot(pts[1][2],rotAxis,-maxAngle*j*vinc);
// rotating around the center pts[1][3] and the axis rotAxis
pts[0][3].rot(pts[1][3],rotAxis,-maxAngle*j*vinc);
new ISurface(pts, 1, 3).clr(0,maxAngle/PI,0);
}
}
}
surf.del();
}
HOME
FOR PROCESSING
DOWNLOAD
DOCUMENTS
TUTORIALS (Java /
Python)
GALLERY
SOURCE CODE(GitHub)
PRIVACY POLICY
ABOUT/CONTACT