Hey people, do you know how to find a distance bet...
# android
n
Hey people, do you know how to find a distance between 2 points along the curve in circle in Canvas?
😶 4
r
n
We want to calculate the distance between 2 points along the path, not distance between 2 points only
👍 1
s
That's simply the percentage of the perimeter of the circle. Get the angle between the points and divide by the total angle in whatever units you use then multiply by the perimeter.
n
Thanks for the answer. We do draw a circle with partitions ( using
drawArc()
). We want to put a space in between these partitions using
PathEffect.dashEffect()
. We know the start angle and *sweep angle (*which are defined in degrees). However the ``dashEffect()`` requires us to give a distance of the partition in
pixels
. Any idea on how to achieve it? That is the reason I asked for the distance along the path of curve. So I can compute it and use it to define the gaps (spacing) in between these ARCHes of CIRCLE
s
If you have the sweep angle and the radius of the circle, the rest is simple maths. ArcLenght = (sweepAngle/360) * (2*Pi * radius)
🚀 1
now you need to define how many dashes you need
n
Awesome Sergio! The formula did the trick, appreciate your help!
👍 1