B4J Tutorial Reflection of a single ray inside a circle

The circle - 0 degrees is measured from the positive x-axis
In the attached sample project the first point (pih_0) is at 324.2 degrees. The second point (phi_1) is at 144.7 degrees
We draw a line from point 1 to point 2 and then reflect the "ray" from there indefinitely using different "HSB" colors (approach angle to the circle boundary = depart angle from the circle boundary relative to the tangent of phi_1)

Once running, change phi_0 and phi_1 with the B4XPlusMinus custom views (click on arrow left/right to change the values of phi_0 and phi_1)
Change the radius with the slider

Drawing is real time.

If phi_0 and phi_1 are 180 degrees apart it will only draw a single line (obviously)
if phi_0 and phi_1 are the same then it will draw "nothing"

It uses the JavaObject library to handle the HSB colors. Every bounce/reflection from the border of the circle changes the color of the ray.
















Enjoy!
 

Attachments

  • b4jCircleBounce.zip
    3.5 KB · Views: 138
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…