[
https://issues.apache.org/jira/browse/GEOMETRY-43?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16768036#comment-16768036
]
Sven Rathgeber commented on GEOMETRY-43:
----------------------------------------
[~mattjuntunen], thanks for working on this.
It works fine, for what I currently need. I find it a little counter-intuitive
to say a line lies on a plane and does not intersect.
I experimented with some helper methods to check this case more comfortably and
make it more explicit.
What do you think ?
{code:java}
// class Plane
/** Check, if the line is parallel to the instance.
* @param line line to check.
* @return true if the line is parallel to the instance, false otherwise.
*/
public boolean isParallel(Line line) {
final Vector3D direction = line.getDirection();
final double dot = w.dot(direction);
if (precision.eqZero(dot)) {
return true;
}
return false;
}
/** Returns the distance of the given line to the plane instance.
* Returns -1.0, if the line is not parallel to the plane instance
* @param line to calculate the distance to the plane instance
* @return the distance or -1.0, if the line is not parallel to the plane
instance.
*/
public double getOffset(Line line) {
if (!isParallel(line))
{
return -1.0;
}
return getOffset(line.getOrigin());
}
/**
* Checks if the line lies on the plane.
* @param line the line to check.
* @return true, if the line lies on the plane. That is: it is parallel to
the plane
* and the offset to the plane is 0.0
*/
public boolean isOnPlane(Line line) {
return precision.eqZero(getOffset(line));
}
{code}
> Check unit test - line intersecting cube (line lies on a plane)
> ---------------------------------------------------------------
>
> Key: GEOMETRY-43
> URL: https://issues.apache.org/jira/browse/GEOMETRY-43
> Project: Apache Commons Geometry
> Issue Type: Task
> Components: Euclidean 3D
> Reporter: Sven Rathgeber
> Priority: Major
> Labels: pull-request-available
> Time Spent: 40m
> Remaining Estimate: 0h
>
> Intersecting a cube with a Line (which lies on a plane) results in one
> intersection only.
>
> Please check the pull request:
> https://github.com/apache/commons-geometry/pull/23
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)