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

Primitive/Operation Requests #45

Open
ghost opened this issue Sep 6, 2019 · 3 comments
Open

Primitive/Operation Requests #45

ghost opened this issue Sep 6, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 6, 2019

This is probably a dumb question, but my knowledge of Julia is limited. I'm trying to do this code:

using Descartes                                                                                                                   
                                                                                                                                  
function create_horse_shape()                                                                                                     
    body_length = 1.0                                                                                                             
    body_width = 1/2 * body_length                                                                                                
    body_thickness = 1/12 * body_length                                                                                           
    body_cutout_circle_radius = body_length / 2                                                                                   
    body_cutout_circle =  Circle(body_cutout_circle_radius)                                                                       
end

when I run create_horse_shape I get this error:

ERROR: MethodError: no method matching Circle(::Float64)
Closest candidates are:
  Circle(::T, ::StaticArrays.SArray{Tuple{3,3},T,2,9}, ::StaticArrays.SArray{Tuple{3,3},T,2,9}) where T at /home/stewart/.julia/dev/Descartes/src/types.jl:16
Stacktrace:
 [1] create_horse_shape() at ./REPL[2]:6
 [2] top-level scope at none:0

How should I use Circle? Thanks.

@sjkelly
Copy link
Member

sjkelly commented Sep 6, 2019

This code ideally would be entirely legitimate. The problem is there is no Circle implemented yet, and it is pulling in the type from GeometryTypes. Re: #26

I think I stopped at figuring out how I wanted 2D shapes to behave. The easiest way is to treat them as 3D shapes, so let's try that first.

@sjkelly
Copy link
Member

sjkelly commented Sep 6, 2019

I pushed the finished up the 2D API for Circles and Squares and pushed it to master. I stuck with similar constraints to what OpenSCAD imposes for now, but later I think these could be relaxed and you should be able to translate a 2D geometry in 3D space.

This is a rough pass and there may be bugs in translating the resultant extrude, so I will keep this issue open.

There is an example here, and output: https://github.com/sjkelly/Descartes.jl/blob/master/examples/2d.jl
image

@ghost ghost changed the title Question Creating Circle Primitive Requests Sep 11, 2019
@ghost ghost changed the title Primitive Requests Primitive/Operation Requests Sep 11, 2019
@sjkelly
Copy link
Member

sjkelly commented Sep 12, 2019

formulations for rounded boxes: https://iquilezles.org/www/articles/distfunctions/distfunctions.htm

I'd actually prefer atomic issues for each subject so there are clear action items.

I agree that the current naming is ambiguous for square. it is supposed to be similar to OpenSCAD. I may move OpenSCADisms into a submodule an go with generic names such as Cuboid, which actually isn't truely correct as implemented AFAIK.

BTW: I have a policy of not looking at libfive source links since it is GPL. Descartes is MIT, so I do not want to risk any issues.

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

1 participant