I had a question, I just can't find the answer. There is an onTouchEvent(event: MotionEvent) and inside I draw a line using Paint. I can't figure out how to get the length of the paint line and find out the refraction, or rather how many degrees like on a picture.
Asked
Active
Viewed 286 times
4
-
I'm a bit confused by this question. You can count the number of pixels you draw or as a set of vectors, calculate the scale for the length. The number of degrees should be the slope of the line depending on what part of the line you are looking at and with respect to which axis (x or y). If you can find two slopes you can work out the angle between the two, see [How can I quantify a drawn line's straightness?](https://gamedev.stackexchange.com/q/98059/6883). Or perhaps if the curve is a Beizer curve, see: [Angle of a given point on a Bezier curve?](https://stackoverflow.com/q/12357200/295004) – Morrison Chang Oct 08 '21 at 08:25
1 Answers
2
Take a look at PathMeasure to get length/points along an arc. Here is an example of an approach you could use.
As for the degrees of an arc, you will need to decide which points to use to produce the tangents you want to compute the value of the angle - different tangents may produce different values.

Cheticamp
- 61,413
- 10
- 78
- 131