Hi,
Here is a math problem that I need to solve.. Please see the attachment.
I have $25 (about 15 pounds sterling) for best answer with b4a demo.
In the attached image, I need to know how to calculate the
lengths of the RED distances (lines) as the pointer moves around Axis X
Please put your solution function in b4a example.
'dx is the distance of x from the center, positive to the right
Sub CalcLength(dx As Double) As Double
Dim alpha As Double
x2 = dx
alpha = ACos(Abs(dx / Radius))
y2 = Radius * Sin(alpha)
If alpha > cPI / 4 Then
y1 = Radius
x1 = Radius / Tan(alpha) * dx / Abs(dx)
Else
y1 = Radius * Tan(alpha)
x1 = Radius * dx / Abs(dx)
End If
Return Sqrt((x2 -x1) * (x2 -x1) + (y2 -y1) * (y2 -y1))
End Sub
Thanks to all who responded this question..
And Klaus wins the prize!
desolatesoul solution looks compact. I didn't test it though.. but there is no demo container.
@ lukaMs: Thanks to you and sorex for the sarcastic comments, realy cool!
If someone put a statement or promise, on the title, then later he put another
statement or promise, then it is the last statement that's valid. I am sure you know but just a reminder.
but your comment was cool and I give it a big LIKE.
Thanks to all who responded this question..
And Klaus wins the prize!
desolatesoul solution looks compact. I didn't test it though.. but there is no demo container.
@ lukaMs: Thanks to you and sorex for the sarcastic comments, realy cool!
If someone put a statement or promise, on the title, then later he put another
statement or promise, then it is the last statement that's valid. I am sure you know but just a reminder.
but your comment was cool and I give it a big LIKE.
thedesolatesoul, perfect!
Well done and take my word, you don't need to try it!.
After NJDude adjustment now working and I test it with all values for ang.
B4X:
rad = 100
For ang = 1 To 90
leng = rad * (Sqrt(Power(SinD(ang),2) + 1) - 1)
Log(leng)
Next