Cette page appartient aux archives web de l'EPFL et n'est plus tenue à jour.
This page belongs to EPFL's web archive and is no longer updated.

# Raphaël Berclaz

HexagonalTower's Code

import oog.*;
import processing.opengl.*;
import processing.dxf.*;
boolean record = false;

Oog goo;

Oog myScene;
Obj myObj = new Obj();
Obj seulementLesSubFaces = new Obj();
Obj splitTower = new Obj();
Sliders mySliders;

public void setup(){
size(1200,800,OPENGL);
frameRate(200);

myScene = new Oog(this);
Scene.drawAxis = true;
Pts.globalRender = new RenderPtsAll();
initForm();
}

//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

void initForm() {

int nbEtages = 30;
int nbPts = 50;            ////////////// numbers of points on each circle /////////////
int h = 25;
int echelle = 20;
float alfa = 2*PI/nbPts;

////////////// a set of transformations /////////////////////

RotateZ cercle = new RotateZ(alfa);
Scale s = new Scale(1,1,1);

///////////// differents parameters ////////////////////

Param hh = new Param(h);

Param ee = new Param(echelle);

//First construction: a basic line
Pts construction = new Pts();

construction.stroke(155,0,0);

////////////////// Creation of the curve //////////////////////

//From this first set of points, create a curve of degree 4
CSpline curve = new CSpline(construction,4);
curve.stroke(255,155,155);

Pts curveWithUniformPts = curve.getPts(nbPts);

Pts[] myLines = new Pts[nbEtages];
Face[] myFloors = new Face[nbEtages];

Pt a = new PtCurve(curve,(0));

for (int i=0 ; i<nbEtages ; i++)
{
myLines[i] = new Pts();
myFloors[i] = new Face();

for (int j=0 ; j<nbPts ; j++) {
Pt aCopy = Pt.create(curveWithUniformPts.pt(j));
a = aCopy;

if (i%2==1)
{
}
}

myLines[i].apply(new TranslateZ(new ParamMul(hh,i)));
myFloors[i].apply(new TranslateZ(new ParamMul(hh,i)));
myLines[i].apply(s);
myFloors[i].apply(s);
myFloors[i].fill(153,153,153);
//myLines[i].apply(cercle);
}

for (int i=0 ; i<myLines.length-2 ; i+=2) {              ///////// boucle pour chaque cercle /////////////////////////////
for (int j=0 ; j<myLines[i].numOfPts()-1 ; j+=2){      ///////// boucle pour chaque points "j" du cercle[i] ////////////

int decal = (i/2)%2+j;
int n = myLines[i].numOfPts();
//int mid = (int)random(1,5);
int mid = 15;

Param mm = new Param(mid);

///////////////////////////////////////////////////////////////////////////////////
/////////////// Définition des 6 sommets de l'hexagone d'orignine /////////////////
///////////////////////////////////////////////////////////////////////////////////

Pt p0  = myLines[i].pt((1+decal)%n);
Pt pa1 = myLines[i+1].pt((0+decal)%n);
Pt pb1 = myLines[i+1].pt((2+decal)%n);
Pt pa2 = myLines[i+2].pt((0+decal)%n);
Pt pb2 = myLines[i+2].pt((2+decal)%n);
Pt p3  = myLines[i+3].pt((1+decal)%n);

//////////////// Création de subdivisions pour chaque diagonales de l'hexagone //////////////

PtsMid vertical = new PtsMid(p0,p3,mid);
PtsMid diagonale = new PtsMid(pa1,pb2,mid);
PtsMid diagonale2 = new PtsMid(pa2,pb1,mid);

Pt pc0 = vertical.pt(1);
Pt pc1 = diagonale.pt(1);
Pt pc2 = diagonale2.pt(1);
Pt pc3 = vertical.pt(mid-1);
Pt pc4 = diagonale.pt(mid-1);
Pt pc5 = diagonale2.pt(mid-1);

seulementLesSubFaces.add(createSubFace(p0, pa1, pb1, pa2, pb2, p3, pc0, pc1, pc2, pc3, pc4, pc5));
}
}

}

///////////////////////////// Création des faces /////////////////////////////////////////

Obj createSubFace(Pt p0, Pt pa1, Pt pa2, Pt p3, Pt pb2, Pt pb1, Pt pc0,Pt pc1, Pt pc2, Pt pc3, Pt pc4, Pt pc5) {

Obj module = new Obj();

Face f1 = new Face();

Face f2 = new Face();

Face f3 = new Face();

Face f4 = new Face();

Face f5 = new Face();

Face f6 = new Face();

////////////////// articulation en 3Dimension /////////////////////
////////////////// création de points normaux aux six faces précédemment créées ////////////////

//int lengtNormal = (int)random(0,8);
int lengtNormal = 5;

Pt ptnorm1 = new PtNormal(f1,-lengtNormal);
Pt ptnorm1b = new PtNormal(f1,0);
Pt ptnorm2 = new PtNormal(f2,-lengtNormal);
Pt ptnorm2b = new PtNormal(f2,0);
Pt ptnorm3 = new PtNormal(f3,-lengtNormal);
Pt ptnorm3b = new PtNormal(f3,0);
Pt ptnorm4 = new PtNormal(f4,-lengtNormal);
Pt ptnorm4b = new PtNormal(f4,0);
Pt ptnorm5 = new PtNormal(f5,-lengtNormal);
Pt ptnorm5b = new PtNormal(f5,0);
Pt ptnorm6 = new PtNormal(f6,-lengtNormal);
Pt ptnorm6b = new PtNormal(f6,0);

/*
Pts construction2 = new Pts();

CSpline curve2 = new CSpline(construction2,4);
*/

//////////// Création des faces liant le pourtour de l'hexagone aux points normaux //////////////

Face face1 = new Face();

Face face2 = new Face();

Face face3 = new Face();

Face face4 = new Face();

Face face5 = new Face();

Face face6 = new Face();

Face face7 = new Face();

Face face8 = new Face();

Face face9 = new Face();

Face face10 = new Face();

Face face11 = new Face();

Face face12 = new Face();

///////////////////////// Faces intérieures //////////////////////////

Face face13 = new Face();

Face face14 = new Face();

Face face15 = new Face();

Face face16 = new Face();

Face face17 = new Face();

Face face18 = new Face();

face1.fill(183,183,183);
face2.fill(183,183,183);
face3.fill(183,183,183);
face4.fill(183,183,183);
face5.fill(183,183,183);
face6.fill(183,183,183);
face7.fill(183,183,183);
face8.fill(183,183,183);
face9.fill(183,183,183);
face10.fill(183,183,183);
face11.fill(183,183,183);
face12.fill(183,183,183);
face13.fill(183,183,183);
face14.fill(183,183,183);
face15.fill(183,183,183);
face16.fill(183,183,183);
face17.fill(183,183,183);
face18.fill(183,183,183);

//Param ln = new Param(lengtNormal);

return module;

}

void draw() {
if (record == true) {
beginRaw(DXF, "output.dxf"); // Start recording to the file
}
background(255);
myObj.draw();
seulementLesSubFaces.draw();
//grid.draw();
if (record == true) {
endRaw();
record = false; // Stop recording to the file
}
}

void keyPressed() {
if (key == 'R' || key == 'r') { // Press R to save the file
record = true;
}
}

Posted by Raphaël Berclaz at 9:12
The HexagonalTower in Manhattan

.

Posted by Raphaël Berclaz at 9:10
module in 3Dimension

Here I developp the module in 3Dimension using normal points.

Posted by Raphaël Berclaz at 10:11
The watercube in construction

We can see that there is a superposition of two grid which are based on the weaired phelan solution.

Posted by Raphaël Berclaz at 10:16
The construction of the house of bubbles

The fassades have a rondomness apparence, but there is a logical way to construct those.

Posted by Raphaël Berclaz at 10:12
Hexagonal Tower, the return

import oog.*;

import processing.opengl.*;

import processing.dxf.*;

boolean record = false;

Oog goo;

Oog myScene;

Obj myObj = new Obj();

Obj seulementLesSubFaces = new Obj();

Sliders mySliders;

public void setup(){

size(1200,800,OPENGL);

frameRate(200);

myScene = new Oog(this);

Scene.drawAxis = true;

//Pts.globalRender = new RenderPtsAll();

initForm();

}

//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////

void initForm() {

int nbEtages = 40;

int nbPts = 40; //////////////numbers of points on the circle/////////////

int h = 10;

int rayon = 50;

float alfa = 2*PI/nbPts;

RotateZ cercle = new RotateZ(alfa);

Scale s = new Scale(1.05,1,.9);

//RotateZ cercle2 = new RotateZ(beta);

Param hh = new Param(h);

Param rr = new Param(rayon);

//Create four first points with absolute coordinates

Pt a = new PtABS();

a.x(rr);

///////////Create circles using array////////////////////////

Pts[] myLines = new Pts[40];

for (int i=0 ; i<nbEtages ; i++)

{

myLines[i] = new Pts();

for (int j=0 ; j<nbPts ; j++) {

Pt aCopy = Pt.create(a,cercle);

a = aCopy;

}

//myLines[i].translate(0,0,i*h);

myLines[i].apply(new TranslateZ(new ParamMul(hh,i)));

myLines[i].apply(s);

}

///////////Create lines between circles////////////////////////

for (int i=0 ; i<20-2 ; i++){ /////////boucle pour chaque cercle

for (int j=0 ; j<nbPts ; j+=1) /////////boucle pour chaque points du cercle

{

int iplus = 0;

if ((i/2)%2==1){

iplus = 1;

}

if(i%2==1) {

if (j%2==0) {

Pts maVerticale = new Pts();

}

}

else {

if (j%2==1) {

Pts maNouvelleLigne = new Pts();

Pts maVerticale2 = new Pts();

maVerticale2.stroke(155,0,0);

}

}

}

}

for (int i=0 ; i<myLines.length-4 ; i+=2) { /////////boucle pour chaque cercle

for (int j=0 ; j<myLines[i].numOfPts()-1 ; j+=2){

int decal = (i/2)%2+j;

int n = myLines[i].numOfPts();

int mid = (int)random(2,10);

Pt p0 = myLines[i].pt((1+decal)%n);

Pt pa1 = myLines[i+1].pt((0+decal)%n);

Pt pb1 = myLines[i+1].pt((2+decal)%n);

Pt pa2 = myLines[i+2].pt((0+decal)%n);

Pt pb2 = myLines[i+2].pt((2+decal)%n);

Pt p3 = myLines[i+3].pt((1+decal)%n);

PtsMid vertical = new PtsMid(p0,p3,mid);

PtsMid diagonale = new PtsMid(pa1,pb2,mid);

PtsMid diagonale2 = new PtsMid(pa2,pb1,mid);

Pt pc0 = vertical.pt(1);

Pt pc1 = diagonale.pt(1);

Pt pc2 = diagonale2.pt(1);

Pt pc3 = vertical.pt(mid-1);

Pt pc4 = diagonale.pt(mid-1);

Pt pc5 = diagonale2.pt(mid-1);

seulementLesSubFaces.add(createSubFace(p0, pa1, pb1, pa2, pb2, p3, pc0, pc1, pc2, pc3, pc4, pc5));

}

}

}

///////////////////////////// Création des faces /////////////////////////////////////////77

Obj createSubFace(Pt p0, Pt pa1, Pt pa2, Pt p3, Pt pb2, Pt pb1, Pt pc0,Pt pc1, Pt pc2, Pt pc3, Pt pc4, Pt pc5) {

Obj module = new Obj();

Face f1 = new Face();

Face f2 = new Face();

Face f3 = new Face();

Face f4 = new Face();

Face f5 = new Face(); ////// en haut à droite

Face f6 = new Face(); ////// en haut à droite

Face f7 = new Face(); ////// en haut à gauche

Face f8 = new Face(); ////// en haut à gauche

Face f9 = new Face(); ////// à gauche

Face f10 = new Face(); ////// à gauche

Face f11 = new Face(); ////// en bas à gauche

Face f12 = new Face(); ////// en bas à gauche

return module;

}

//Create Sliders based on an object

//myScene.sliders(myObj);

//goo.sliders(myObj2);

void draw() {

if (record == true) {

beginRaw(DXF, "output.dxf"); // Start recording to the file

}

background(255);

myObj.draw();

seulementLesSubFaces.draw();

if (record == true) {

endRaw();

record = false; // Stop recording to the file

}

}

void keyPressed() {

if (key == 'R' || key == 'r') { // Press R to save the file

record = true;

}

}

Posted by Raphaël Berclaz at 16:37
Hexagonal tower

import oog.*;

import processing.opengl.*;

Oog goo;

Oog myScene;

Obj myObj = new Obj();

Sliders mySliders;

public void setup(){

size(800,400,OPENGL);

frameRate(200);

myScene = new Oog(this);

Scene.drawAxis = true;

initForm();

}

void initForm() {

//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////

int nbPts = 16;

int h = 10;

int rayon = 40;

float alfa = 2*PI/nbPts;

RotateZ cercle = new RotateZ(alfa);

Translate t1 = new Translate(0,0,h);

//Create four first points with absolute coordinates

Pt a = Pt.create(rayon,0);

///////////Create circles using array////////////////////////

Pts[] myLines = new Pts[20];

for (int i=0 ; i<20 ; i++)

{

myLines[i] = new Pts();

for (int j=0 ; j<nbPts ; j++) {

Pt aCopy = Pt.create(a);

aCopy.apply(cercle);

a = aCopy;

}

myLines[i].translate(0,0,i*10);

}

///////////Create lines between circles////////////////////////

for (int i=0 ; i<20-1 ; i++){

for (int j=0 ; j<nbPts ; j+=2)

{

int iplus = 0;

if ((i/2)%2==1){

iplus = 1;

}

if(i%2==0) {

Pts maNouvelleLigne = new Pts();

}

else {

Pts maNouvelleLigne = new Pts();

}

}

}

//Create Sliders based on an object

myScene.sliders(myObj);

//goo.sliders(myObj2);

}

void draw() {

background(255);

myObj.draw();

}

Posted by Raphaël Berclaz at 17:53
The Splittower

import oog.*;

import processing.opengl.*;

Oog myScene;

Obj myObj = new Obj();

Obj splitTower = new Obj();

Sliders mySliders;

public void setup(){

size(1200,800,OPENGL);

frameRate(200);

myScene = new Oog(this);

Scene.drawAxis = true;

mySliders = new Sliders();

initForm();

}

void initForm(){

//Definition of shape parameters

int numOfSides = 8;

float theta = 2*PI/numOfSides;

//Create a first point with absolute coordinates

Pt a = Pt.create(20,20);

// rotation

RotateZ r = new RotateZ(theta);

//Create a new Face

Face mySquare = new Face();

for (int i=0; i<numOfSides; i++) {

//Create a point from a previous

Pt newPt = Pt.create(a,r);

a = newPt;

}

Obj oriSquare = new Extrude(mySquare,Pt.create(0,0,-4));

//Create a new set of Transformations

Transform myTransform = new Transform();

myTransform.translate(0,0,3);

Transform myTransform2 = new Transform();

myTransform2.apply(myTransform);

myTransform2.scale(.97,.97,1);

//myTransform2.rotateZ(2*PI/72);

Obj mySquare2 = new Obj(oriSquare);

for(int i=0; i<80; i++)

{

Obj tmp = new Obj(mySquare2);

if(i<50)

tmp.apply(myTransform);

else

{

Origine fromHere = new Origine(mySquare2.face(0).pt(0),myTransform2);

tmp.apply(fromHere);

}

mySquare2 = tmp;

}

myObj.translate(20,20,0);

RotateZ rotZ = new RotateZ(PI/4);

Obj oriObj = myObj;

for(int i=0; i<8; i++)

{

Obj rotatedPart = new Obj(oriObj);

rotatedPart.apply(myTransform);

rotatedPart.apply(rotZ);

oriObj = rotatedPart;

}

myScene.sliders(splitTower);

}

void draw(){

background(255);

splitTower.draw();

mySliders.draw();

}

Posted by Raphaël Berclaz at 9:24
Exercice2

The Spiral Tower

Codes pour 4 spirales tournant dans le même sens:

for(float i=1; i<=10; i=i+0.05) {

}

for(float i=1; i<=10; i=i+0.05) {

}

for(float i=1; i<=10; i=i+0.05) {

}

for(float i=1; i<=10; i=i+0.05) {