Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash on weird shape #41

Closed
nickodell opened this issue Sep 24, 2017 · 3 comments
Closed

Crash on weird shape #41

nickodell opened this issue Sep 24, 2017 · 3 comments

Comments

@nickodell
Copy link
Contributor

This works, and renders a cylinder:

(extrude-z
(lambda-shape (x y z)
 (define r (sqrt (+ (expt x 2) (expt y 2))))
 (define theta (atan (/ y x)))
 (- r (+ 2)))
0 1)

This crashes:

(extrude-z
(lambda-shape (x y z)
 (define r (sqrt (+ (expt x 2) (expt y 2))))
 (define theta (atan (/ y x)))
 (- r (+ 2 theta)))
0 1)

It gives this error:

Studio: /home/nick/ao/ao/src/render/brep/mesh.cpp:39: void Kernel::Mesh::load(const std::array<const Kernel::XTree<3u>*, 4ul>&) [with Kernel::Axis::Axis A = (Kernel::Axis::Axis)4u; bool D = false]: Assertion `vi != -1' failed.
Aborted

I can sometimes get this to run and produce a shape, though it isn't solid - which might be because theta isn't defined for x=0. Is there a better way to define an object in polar coordinates?

(Lemme know if the problem is that I'm using ao in an unsupported way.)

@mkeeter
Copy link
Member

mkeeter commented Sep 24, 2017

I think you're right and that it's failing when x=0. It's a bit rude to put divisions by zero into the meshing system, but the kernel should be robust enough to not crash, so I'll look into this.

As a workaround, when I switch to the two-argument form (atan y x) it renders... something.

mkeeter added a commit that referenced this issue Sep 25, 2017
This probably fixes issue #41.
@mkeeter
Copy link
Member

mkeeter commented Sep 25, 2017

Okay, I think I've tracked this down and fixed it. The shape is still odd-looking, but I think that's because it's a weird shape with discontinuities where atan wraps.

Please re-open if you see more crashing.

@mkeeter mkeeter closed this as completed Sep 25, 2017
@nickodell
Copy link
Contributor Author

Yep, this is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants