- lets say i got plane in 3d in any rotation and any location.
- it also have some width and height.(because its a plane or can be named 2Dbox, like in 2d)
- i raycast it receiving contact point.
First question: How can i receive 2d point(or percent values of width and height) of this plane from this contact point?
what myself i invent(not a good solution ;p) was:
Vector3f minTranslation = element.getWorldTranslation(); // start point of plane Vector3f xMaxTranslation = element.getWorldXTranslation(); // end x point of plane Vector3f yMaxTranslation = element.getWorldYTranslation(); // end y point of plane float minDistance = minTranslation.distance(lastContactPoint); // contact point distance to start plane float percentX = minDistance / (minDistance + xMaxTranslation.distance(lastContactPoint)); float percentY = minDistance / (minDistance + yMaxTranslation.distance(lastContactPoint));
it almost work, but it dont because ofc when point will be at width 100% and height 100% it will calculate like 50% and 50%. when point will be at width 100% height 0% it will be correct, same correct for point in 0% and 0%.
ofc i need closest point to width or height vector line to make distance work correctly.
So Second question: how can i receive closest point to other vector line. (so it might fix my solution)