To model the lamp I decomposed it in three parts:
- the upper part of the lamp
- the lower part of the lamp
- the bulb(and the wire)
Before building the various parts of this object I found useful to implement variuos support functions.
One of them, the CIRCLE_BEZIER
allows me to create a circle with Bezier curves, by passing the radius and the Z coordinate on which I desire to obtain this circle.
function CIRCLE_BEZIER(r,z){
var rot_domain = DOMAIN([[0,1],[0,2*PI]])([40,40]);
var p1 = [[r,0,z],[r*COS(PI/12),r*SIN(PI/12),z], [r*COS(PI/6),r*SIN(PI/6),z], [r*COS(PI/4),r*SIN(PI/4),z], [r*COS(PI/3),r*SIN(PI/3),z], [r*COS(5*PI/12),r*SIN(5*PI/12),z], [0,r,z]];
var c1 = BEZIER(S0)(p1);
return c1;
};
With this function I modeled the upper and the lower part of the lamp, in combination with the BEZIER
function and a simple mapping.
Then, to model the bulb, I used the ROTATIONAL_SURFACE
function:
//Other code..
var domain = DOMAIN([[0,1],[0,2*PI]])([20,20]);
var profile = BEZIER(S0)([[0,0,0],[0.5,0,0.5],[2,0,2],[2,0,4],[0,0,5]]);
var mapping = ROTATIONAL_SURFACE(profile);
var surface = MAP(mapping)(domain);
//Other code..
Structuring all these parts, I obtained the lamp.