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

Rectangle Surface Primitive and Integration with Box #156

Merged
merged 11 commits into from
May 17, 2021

Conversation

hervasa2
Copy link
Collaborator

Definition and plotting for Rectangle Surface Primitive. Rectangles are restricted to have normal vectors on x, y, or z

  • Functions: in(), sample()
  • Pending: distance_to_surface(). To be added along with that of prism surfaces.
  • Pending: sample() with ticks

Box now has get_decomposed_surfaces(). It gets decomposed into two of each: Rectangle{T, Val{:x}}, Rectangle{T, Val{:y}}, Rectangle{T, Val{:z}} unless one of the dimensions is zero.

Screen Shot 2021-05-13 at 5 33 58 PM

Screen Shot 2021-05-13 at 5 33 42 PM

Screen Shot 2021-05-13 at 5 33 24 PM

Screen Shot 2021-05-13 at 5 32 27 PM

@hervasa2 hervasa2 requested a review from fhagemann May 13, 2021 15:45
Copy link
Collaborator

@fhagemann fhagemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👍

Some comments:

  • I find the surface primitives Square from RegularPrism and Rectangle from Box quite similar. People might think that a square Rectangle might be a Square, so we should discuss whether we want to rename Square then.
  • For the Rectangle constructors: what do you think about introducing aliases
    (e.g. RectangleX = Rectangle{<:Any, Val(:x)})?
    Because I do not think it is the user-friendliest option to use Val(:x) as input for Rectangle.
    Also, it would allow getting rid of most of the Val(:x) in the code.

Comment on lines 52 to 58
return AbstractSurfacePrimitive[Rectangle(b, Val(:x), xMin)]
elseif isapprox(yMin, yMax, atol = tol)
return AbstractSurfacePrimitive[Rectangle(b, Val(:y), yMin)]
elseif isapprox(zMin, zMax, atol = tol)
return AbstractSurfacePrimitive[Rectangle(b, Val(:z), zMin)]
else
return AbstractSurfacePrimitive[
Copy link
Collaborator

@fhagemann fhagemann May 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove AbstractSurfacePrimitive before the [?
Julia will know that this is a Vector{Rectangle} and convert it to a Vector{AbstractSurfacePrimitive}, e.g. when determining the decomposed surfaces of contacts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've had this conversation before. This also happens with the Sphere and in some other specific cases. The AbstractSurfacePrimitive is there for consistency. This is still a pending issue that deserves its own PR

@fhagemann
Copy link
Collaborator

fhagemann commented May 14, 2021

I added the sample functions with CartesianTicksTuple and CylindricalTicksTuple.

The sampling with CartesianTicksTuple is extremely straightforward.
The Rectangles are sampled at their edges and all the grid ticks in between:
Sample_Cartesian
Sample_offset_Cartesian

The sampling with CylindricalTicksTuple is a bit more tricky.
For each φ, the intersections with the four edges of the Rectangle at positive radii are determined. This can be zero (no intersection), one (the Rectangle includes the origin of the coordinate system), or two (the Rectangle has an offset and does not include the origin of the coordinate system). Then, all ticks in r between the intersection points are sampled with the grid spacing as step size:
Sample_Cylindrical
Sample_offset_Cylindrical

Especially the sampling with CartesianTicksTuple might need some nice polishment but it should work for now.

@fhagemann
Copy link
Collaborator

fhagemann commented May 15, 2021

I would like the sampling of Rectangle to also sample intersections of r ticks with the edges and not only the intersection of the φ ticks. This would result in more samples on the blue lines in this figure (especially the top left of the Rectangle):

Sample_offset_Cylindrical

Let me work on this before we merge.

@fhagemann
Copy link
Collaborator

Sampling with CylindricalTicksTuple now also includes sample points at r-ticks on the edges:

Sampling only at r ticks

sample_at_r_ticks

Combined sampling

Sample_offset_Cylindrical_updated

The corners of a Rectangle are not explicitly sampled. However, when creating the Grid, the "important points" of the Rectangle will be added such that the corners will "naturally" be sampled at a specific r and φ tick.

@fhagemann fhagemann merged commit 68f90b8 into JuliaPhysics:v0.6 May 17, 2021
@fhagemann fhagemann mentioned this pull request May 17, 2021
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

Successfully merging this pull request may close these issues.

3 participants