I have a visual 2d representation of a coordinate system, and a bezier graph with control points represented using a circle graphic. I need to be able to scale the coordinate system including the graph along a given axis, the same way a coordinate system can be scaled on a calculator or similar, to see the graph better. But I need the points' graphic to not be distorted. We could do this easily by applying the scaled matrix, then applying the model matrix and finally applying the inverse of the scaled matrix. Thus the final 3x3 matrix applied in the vertex shader for the control points' graphic would be:


While the matrix for the coordinate system and the graph would be:


Now the issue I'm having however is that I need to be able to select the control points. Normally to do this we would need to first calculate the cursor position in the world coordinates, by applying the inverse of projection-view matrix on the device coordinates of the cursor as below. We would then check for intersection between this point and the circle formed by each control point and the radius of the graphic.

vec2 cursorPos = vec2(inverse(ProjView*ScaledMatrix)*vec3(cursorDeviceCoord,1))`

However the issue is that in this case applying the inverse of ProjView*ScaledMatrix would lead to us picking a distorted shape. Basically we would be picking the points' circle graphic for which we didn't apply the InverseScaledMatrix.

Is there any good way to solve this problem? I have been struggling with this for some time but can't come up with anything.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.