Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

lookup function returns unexpected result [$20 awarded] #322

Closed
MichaelAtOz opened this Issue · 15 comments

6 participants

@MichaelAtOz

Playing with the lookup function, it seems to return incorrect result for key>(max key in vector)

eg

v=[ [-200, 60],
    [-170, 40],
    [-150, 30],
    [-100, 20],
    [-50,  10],
    [-5,    5],
    [0,    -5],
    [100,-50],
    [150, -80],
    [210, -100],
    ];
for (i=[-250:25:250]) {
    translate([i,0,((lookup(i,v)<0)? lookup(i,v) : 0)]) 
        cube([10,10,abs(lookup(i,v))]);
    echo(i,lookup(i,v));
}
for (i=[0:len(v)-1])
    translate([v[i][0],-10,((v[i][1]<0)? v[i][1] : 0)]) 
        color("red",0.2)
            cube([10,10,abs(v[i][1])]);

produces
OpenSCAD lookup
I would have though for >=210 it should return -100, (or perhaps interpolate from the last two points).

The $20 bounty on this issue has been claimed at Bountysource.

@kintel
Owner

We don't have a testcase for the lookup function. This should be added while fixing this issue.

@NateTG NateTG referenced this issue
Merged

Update func.cc #358

@NateTG

Sorry, still figuring out git, and testcase stuff
Lines 357-360 of func.cc should be:
if (p <= low_p)
return Value(high_v);
if (p >= high_p)
return Value(low_v);
instead of
if (p <= low_p)
return Value(low_v);
if (p >= high_p)
return Value(high_v);

@kintel kintel referenced this issue from a commit
@kintel kintel Added testcase for #322 3780677
@kintel kintel closed this
@kintel
Owner

Nate fixed it. Nate: there is a $20 experimental bounty on this issue. Claim it if you want :) ..or re-bounty if you didn't do it for the bounty.

@NateTG

I was wondering about that. The bounty thing confuses me a little. (I'm a bit slow at times.) I submitted it, I guess I have to wait two weeks now.

@kintel
Owner

The bounty is an ongoing experiment in trying to motivate people to contribute to OpenSCAD, both because we need more developers, and because we're uncertain what is missing in order to facilitate new developers getting started.

@TakeItAndRun
@TakeItAndRun
@GilesBathgate

About 2 years ago I had a similar idea to this "Bug Bounty", and drafted up a blog post titled "Micro Employment" Basically the idea was to offer bitcoins in payment for making improvements to the RapCAD. I decided that the idea was unfairly competitive and so never went through with it. (I even went so far as buying $10 worth of bitcoins, which are worth a lot more now than what I paid for them) I might revisit the idea, as I would really like to re-ignite adoption of RapCAD. It has a lot of great features, and although there has been interest in porting some of these into OpenSCAD I think some of them would require architectural changes that are too high risk for OpenSCAD to adopt at this time. On the other hand RapCAD is missing a robust implementation of linear_extrude() and completely lacking rotate_extrude() So completion of those modules would be the first things I would offer up a bounty for. Is anyone interested?

@kintel
Owner

I think architecture changes to OpenSCAD will happen, gradually, so it's mostly a matter of taking the time to refactor code to allow for this to happen, and keep writing tests to ensure nothing breaks in the process.

One of the major differences is that RapCAD strategically didn't go for a preview mode, which makes it possible to utilize CGAL in a more coherent fashion, while OpenSCAD strives towards using CGAL only for the final compilation and not for preview (we're not quite there yet though).

..and I do like the cleanliness of your parser code :)

@GilesBathgate

The architectural differences I had in mind were declarative vs imperative (i.e variables that can change), and the 2D subsystem implemented using 3D. I've never been really interested in implementing a lot of things that OpenSCAD already does. What's the point right? it would be just re-inventing the wheel. On the other hand I've had to re-implement some things, otherwise it wouldn't be useable. That brings me to the point you make about OpenCSG preview, I didn't have much interest in implementing that. OpenSCAD already does this well, so I would just be copying code for the sake of it. It does make it coherent, but it can be slow. There is also no caching of CGAL objects which doesn't help the speed either. Those things aside, implementing linear_extrude() and rotate_extrude() seem pointless as well at first glance since OpenSCAD already implements those. But as I have mentioned before, I am trying to implement those modules using 3D primitives, and CGAL doesn't seem to offer a neat way of doing this easily.

@donbright
Collaborator

how much is the bounty?

@GilesBathgate

I am thinking a couple of bitcoins for each of the above two modules. I am opening issues in RapCAD to continue discussion there.

Regards,
Giles

@NateTG

..or re-bounty if you didn't do it for the bounty.

Any particular place you'd like to see it? Otherwise, I'll just send it to the EFF.

@kintel
Owner

The idea of the bounty was to motivate new developers to get involved, combined with motivating non-developers to add to the bounty, creating more motivation. Not sure it will work and if we should focus on features vs. bugs.
In terms of features, SVG import, svg export, obj export are nice and stand-alone.
Otherwise, there are tons of bugs and other issues. Put it where you want to see improvement.

@donbright donbright referenced this issue from a commit
@NateTG NateTG Update func.cc
Fix for #322
715d539
@kintel kintel changed the title from lookup function returns unexpected result to lookup function returns unexpected result [$20 awarded]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.