-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add LineTest #1567
base: master
Are you sure you want to change the base?
Add LineTest #1567
Conversation
The thing is that JME's math in Line looks right. I can't make sense of your findNearestPoint(), though. It seems to be treating direction like an end point instead of a direction vector. For example: float vecX = line.getDirection().x - line.getOrigin().x; ...makes no sense to me. Math should be: I wonder if you add an assert to test your own methods against each other if they will even match. |
I am not sure if we misunderstood the definition of distance in JME. According to the javadoc of JME, the direction is the second point other than the origin, so the vecX you mentioned is the vector with origin as the tail and the specific point as the head. The findNearestPoint() is to find out the point on the line that has shortest distance with the specific point.
|
Vector3f direction = new Vector3f(2,0,0); Normalize it. |
I understand that the direction is not a vector, so vecX = line.getDirection().x - line.getOrigin().x is to make it as an x component vector. |
JME expects direction to already be normalized. This is true across the entire codebase. Everywhere you see "direction" then it should be normalized. Some places have asserts to check it for you. Some places normalizeLocal() for you (possibly redundantly) but probably MOST places expect direction to already be normalized. So in your test, change: Vector3f origin = new Vector3f(0,70,0);
Vector3f direction = new Vector3f(1,8,0);
Vector3f point = new Vector3f(32,1,8); To: Vector3f origin = new Vector3f(0,70,0);
Vector3f direction = new Vector3f(1,8,0).normalizeLocal();
Vector3f point = new Vector3f(32,1,8); ...if you want accurate results. |
Thanks a lot for the information. We will look into our test methods and make it works to increase the test coverage. |
This test is to increase the test coverage, and the feature we tested was the distance method in the Line class.
We used a dot product method, and a cross product method to find the distance, which had the same results. However, we found out an issue that the jMonkey’s output for distance was different, and should be incorrect according to how the actual math works. The test case was intended to give a failed test because the calculations for the distance seemed to not match the actual calculations.