Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float[] vertices = triangle.getTransformedVertices();
- float distance = Intersector.distanceLinePoint(vertices[2], vertices[3], vertices[4], vertices[5], vertices[0], vertices[1]);
- Vector2 vertex0 = new Vector2(vertices[0], vertices[1]);
- Vector2 vertex1 = new Vector2(vertices[2], vertices[3]);
- Vector2 vertex2 = new Vector2(vertices[4], vertices[5]);
- Vector2 nearest = new Vector2();
- Intersector.nearestSegmentPoint(vertex1, vertex2, vertex0, nearest);
- Vector3 v = new Vector3(vertex2, 0).sub(vertex0.x, vertex0.y, 0).nor();
- v.scl(v.dot(new Vector3(vertex1.sub(vertex0), 0)));
- v.sub(new Vector3(vertex1.sub(vertex0), 0).nor());
- System.out.println("d:"+distance +", nearest:"+nearest.nor() + ", another d: " + Math.sqrt(Math.pow(nearest.x - vertex0.x, 2)+Math.pow(nearest.y - vertex0.y, 2)));
- System.out.println(v);
- Console:
- d:45.254833, nearest:[0.3846154:0.9230769], another d: 373.55147054776813
- 0.40613845,0.9138115,0.0
- d:28.62167, nearest:[0.5098024:0.8602915], another d: 372.1809403175402
- 0.5547002,0.83205026,0.0
- d:22.627417, nearest:[0.98724115:0.15923244], another d: 519.9225805360841
- 0.97014254,0.24253564,0.0
- d:22.627417, nearest:[0.98257023:0.18589166], another d: 614.5327782895729
- 0.98893636,0.14834045,0.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement