[
https://issues.apache.org/jira/browse/GEOMETRY-32?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16935037#comment-16935037
]
Matt Juntunen commented on GEOMETRY-32:
---------------------------------------
{quote}Wrong link.
{quote}
Oops. Here it is: [https://en.wikipedia.org/wiki/Region_(mathematics)]
{quote}Hence, shouldn't we hide this _implementation detail_ from the public API
{quote}
Yes. The fact that our hyperplane-bounded regions need to have their inside and
outside flipped in some situations is an implementation detail and is _not_
part of the public API. Users pass arbitrary {{Transform}} instances to the
regions and this logic is handled internally. However, the fact that some
{{Transform}} instances preserve spatial orientation _is_ part of the public
API, since it is a property of the transforms themselves. Users should not need
to worry about it unless they're implementing their own {{Transform}} classes,
which seems uneccessary. The provided classes handle all of the logic
transparently. Here are some examples. Note that I changed the method name from
{{preservesHandedness}} to {{preservesOrientation}} to be more generic.
{code:java}
// create some matrix transforms
Transform2D translate =
AffineTransformMatrix2D.createTranslation(Vector2D.of(1, 2));
translate.preservesOrientation(); // true
Transform2D reflectX = AffineTransformMatrix2D.createScale(-1, 1);
reflectX.preservesOrientation(); // false
// create some function-based transforms
Transform2D scale = FunctionTransform2D.from(p -> p.add(Vector2D.of(1, 2)));
scale.preservesOrientation(); // true
Transform2D reflectY = FunctionTransform2D.from(p -> Vector2D.of(p.getX(),
-p.getY()));
reflectY.preservesOrientation(); // false
// transform some regions
RegionBSPTree2D tree = createTree();
tree.transform(translate); // no inside/outside flipping
tree.transform(reflectY); // flips inside/outside
{code}
> BSPTree Updates
> ---------------
>
> Key: GEOMETRY-32
> URL: https://issues.apache.org/jira/browse/GEOMETRY-32
> Project: Apache Commons Geometry
> Issue Type: Improvement
> Components: core
> Reporter: Matt Juntunen
> Priority: Major
> Labels: pull-request-available
> Time Spent: 20m
> Remaining Estimate: 0h
>
> The following updates should be made to the BSPTree class:
> - add an {{isLeaf()}} method to replace all of the {{node.getCut() == null}}
> expressions
> - add unit tests
> _Edit [2019-02-17]:_
> Additional goals:
> - Refactor the API to split the idea of a general BSPTree and a BSPTree used
> for defining in/out regions. This could result in a BSPTree interface and a
> RegionBSPTree interface. The goal here is to allow end-users to create their
> own extensions of these classes and specialize them for their own
> applications (for example, to implement spatial sorting or other algorithms).
> This will be one of the only planned extension points in the library.
> - Make the API easier to use and extend and reduce the necessity of casting
> (especially unchecked casting) as much as possible.
> - Add the idea of convex subhyperplanes to allow for more efficient tree
> construction.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)