I have a situation in which I need to know if the distance between a Position2D node and the outside edge of an Area2D node is greater than a given length variable. The Position2D node is just barely inside the Area2D node, on one edge essentially, and I want to know the distance from that point to the "next" or adjacent edge of the Area2D node (a hypothetical solution: RayCast2D emitted from the Position2D parallel to the edge the Position 2D is immediately inside of; yet how do I get the distance value?).

What are some other solutions? I might be able to place additional Area2D nodes outside of the first, and then check if the RayCast2D ends up inside those, but I'm still not sure how to get the length of the ray segment that is inside or outside of the original Area2D.

For greater context: I am making a cycloid generator, and need "wheels" (just n-sided regular polygons) to turn around a "floor" shape (also an n-sided polygon) without "slipping," "sliding," or passing through the "floor" shape. I know how to calculate the desired rotation of any given turn of the "wheel," but there are some cases in which the wheel needs a new rotation point to be placed in-between its corners. This is the problem I'm trying to solve: where on the "wheel's" side (of known length) should the new point be created in order to rotate the "wheel" so another new point on the "wheel's" corner is in contact with the "floor"?

Please let me know if you'd like me to elaborate on any of these points, thanks!

EDIT: I just realized I was describing an older version of my project; I no longer am using Area2D nodes, just RegularPolygon2D nodes from this project: https://github.com/RoboYorkie/Godot_RegularPolygon2D
I could certainly re-implement them, though. Just wanted to give a clearer picture of where I am currently.

Further edit: this website has a magical ability to give you the answer just by the introspective writing process :P
The current plan is to get the length of each "floor" side (all are equal, since its a regular polygon), and modulo(floorsidelength, wheelsidelength) is equal to the distance value I had been searching for! I just need to do that math for each complete traversal of "wheel" across any given side of "floor." I'd still like to hear your ideas :)

`distance_from_old_point_to_new_point = fmod(floor_side_length, wheel_side_length)`