Code not working

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Code not working

unkerjay
"We can make solid surfaces by reducing the step size so the cylinders overlap but its slow and the result is poor. A better approach is to use hull() to join adjacent cylinders.

module slice(x,thickness) {
    assign(pa = f(x))
    assign(pb = g(x))
    assign(length = norm(pb-pa))
    orient_to(pa,pb-pa)
        cylinder(r=thickness,h=length);  
};

module ruled_surface(limit,step,thickness=1) {
 for (x=[0:step:limit-step])
  hull() {
      slice(x,thickness);
      slice(x+step,thickness);
  }
};"

from here:

http://kitwallace.tumblr.com/post/85509667344/surfaces-rule-ok

which refers, I think, to the image just above the code.

I get:

"WARNING: No top level geometry to render"

There's a rest of the story.  I have no clue.

I've been looking long and hard for something like this.

I'd really like it to work.

Anyone?
Reply | Threaded
Open this post in threaded view
|

Re: Code not working

unkerjay
P.S.

I'm in Linux (Linux Mint), using Openscad v2014.03.

Anything newer, I have not been able to get to work.
Reply | Threaded
Open this post in threaded view
|

Re: Code not working

unkerjay
P.P.S

I think it's either a ruled paraboloid or a doubly ruled surface hyperbolic paraboloid:

https://en.wikipedia.org/wiki/Paraboloid#mediaviewer/File:Hyperbolic-paraboloid.svg

Reply | Threaded
Open this post in threaded view
|

Re: Code not working

kintel
Administrator
In reply to this post by unkerjay
You copied only half of the code you linked to.
If you include the remaining part of his code it works as it should.

 -Marius


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Code not working

unkerjay
Well, I think this is all the code there is:

 module orient_to(origin, normal) {  
      translate(origin)
      rotate([0, 0, atan2(normal.y, normal.x)]) //rotation
      rotate([0, atan2(sqrt(pow(normal.x, 2)+pow(normal.y, 2)),normal.z), 0])
      child();
}

module ruled_surface(limit,step) {
 for (x=[0:step:limit])
    assign(pf = f(x))
    assign(pg = g(x))
    assign(length = norm(pg  - pf))
    orient_to(pf, pg - pf)
        cylinder(r=Line_radius,h=length);  
};


function f(a) = [ Radius * cos(a),
                       Radius * e * sin(a),
                       0];
function g(a) = [ Radius * cos(a+Phase),
                   Radius * e * sin(a + Phase),
                   0]
                 + [0,0,Height];


Phase = 120;
Height = 60;
Radius = 20;

Line_radius=1.5;
e=1.5;
Step=10;
ruled_surface(360,Step);  

function norm(v) =
    pow(v.x*v.x + v.y*v.y + v.z*v.z,0.5);

function f(x,p) = [0,0,x*Height];
function g(x,p) = [Radius * cos(x*360*Revs),
                          Radius * sin(x*360*Revs),
                          x*Height];

Height=60;
Radius=20;
Revs=2;
Steps=200;
Step=1/Steps;
Thickness=1;
Sides=10;


$fn= Sides;
ruled_surface(1,Step,Thickness);

module orient_to(origin, normal) {  
      translate(origin)
      rotate([0, 0, atan2(normal.y, normal.x)]) //rotation
      rotate([0, atan2(sqrt(pow(normal.x, 2)+pow(normal.y, 2)),normal.z), 0])
      child();
}

module ruled_surface(limit,step,params) {
 for (x=[0:step:limit])
    assign(pf = f(x,params))
    assign(pg = g(x,params))
    assign(length = norm(pg-pf))
    orient_to(pf,pg-pf)
        cylinder(r=Line_radius,h=length);  
};

function f(a,phase) = [ Radius * cos(a),
                        Radius * e * sin(a),
                       0];
function g(a,phase) = Top_ratio * [ Radius * cos(a+phase),
                   Radius * e * sin(a + phase),
                   0]
                 + [0,0,Height];


Phase=120;
Height = 60;
Radius = 20;

Line_radius=1.5;
e=1.5;
Top_ratio = 0.8;

Step=20;

union(){
   ruled_surface(360,Step,Phase);
   ruled_surface(360,Step,-Phase);
}

function f(x,p) = p[0] + x/Length * (p[1] - p[0]);
function g(x,p) = p[2] + x/Length * (p[3] - p[2]);

Length=40;
Width=40;
Height=60;
Steps=10;
Step=Length/Steps;
Thickness=3;
Sides=10;
p = [
    [0,0,0],
    [0,Width,0],
    [Length,Width,0],
    [Length,0,0],
    [0,0,Height],
    [0,Width,Height],
    [Length,Width,Height],
    [Length,0,Height]
    ];

$fn= Sides;
ruled_surface(Length,Step,Thickness,[p[0],p[2],p[5],p[7]] );
ruled_surface(Length,Step,Thickness,[p[0],p[5],p[2],p[7]] );

module slice(x,thickness) {
    assign(pa = f(x))
    assign(pb = g(x))
    assign(length = norm(pb-pa))
    orient_to(pa,pb-pa)
        cylinder(r=thickness,h=length);  
};

module ruled_surface(limit,step,thickness=1) {
 for (x=[0:step:limit-step])
  hull() {
      slice(x,thickness);
      slice(x+step,thickness);
  }
};

Put it all together.

Here's what I've got:

"WARNING: No top level geometry to render"

Now which half and how, still a mystery.
Reply | Threaded
Open this post in threaded view
|

Re: Code not working

kintel
Administrator
You just pasted a whole bunch of mixed-up code.
If you read the article and use the components as described, you should have more luck.
e.g. the hyperboloid code from the article appended verbosely below.

 -Marius

 module orient_to(origin, normal) {  
      translate(origin)
      rotate([0, 0, atan2(normal.y, normal.x)]) //rotation
      rotate([0, atan2(sqrt(pow(normal.x, 2)+pow(normal.y, 2)),normal.z), 0])
      child();
}


module ruled_surface(limit,step) {
 for (x=[0:step:limit])
    assign(pf = f(x))
    assign(pg = g(x))
    assign(length = norm(pg  - pf))
    orient_to(pf, pg - pf)
        cylinder(r=Line_radius,h=length);  
};


function f(a) = [ Radius * cos(a),
                       Radius * e * sin(a),
                       0];
function g(a) = [ Radius * cos(a+Phase),
                   Radius * e * sin(a + Phase),
                   0]
                 + [0,0,Height];


Phase = 120;
Height = 60;
Radius = 20;

Line_radius=1.5;
e=1.5;
Step=10;
ruled_surface(360,Step);  
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Code not working

QuackingPlums
In reply to this post by unkerjay
Hey, I don't know why you felt you had to delete your posts but we're all friends here so you shouldn't feel that you have anything to hide.
We all had to ask for help at one point and reading these conversations is a great way to learn. In any case, this discussion forum is a bit different from most in that it is actually just a layer on top of a mailing list – all posts are automatically sent to all subscribers so deleting posts has a limited effect (there was nothing I could see that warranted your self-moderation by the way).

Anyway, we hope you enjoy exploring the capabilities of OpenSCAD and look forward to helping you with your next query. :-)
Reply | Threaded
Open this post in threaded view
|

Re: Code not working

kitwallace
Indeed , as the author of the article and code in question, I would have been interested to see what problems you were having with the code so I can improve the article.  

Chris