As the title suggests, I don't know where to start on this problem: I have a a 2D plane defined by it's origin point in global coordinates(x,y,z) and its axis endpoints as well, but I don't know how to return the local coordinates of a point on the plane
I found this solution but it gave false results:
// given information
`Vector3 origin;
Vector3 planeXDir;
Vector3 planeYDir;
Vector3 pointOnPlane;
Vector3 v = pointOnPlane - origin;
Vector2 positionInPlane = new Vector2(Vector3.Dot(planeXDir, v), Vector3.Dot(planeYDir, v));`
I don't know where I went wrong, maybe a misconception of planeXDir and planeYDir? I'd be happy if someone could explain or give me an easier solution to implement.
CodePudding user response:
That code is correct, so there're misconceptions or mistakes somewhere. Check that planeXDir & planeDir are orthogonal, and unit (or if not unit that you really want a scaling difference between unit lengths in 3D vs the plane).