I'm currently trying--as part of implementing a new feature--to find the point on a squashed circle that is nearest to the player's location.
The circle in question is squashed simply by the application of a scalar applied to its x-axis.
I already have code that can determine the nearest point on an unsquashed circle, I do believe. And it seems to me that there should be a relationship between this point and the equivalent point on the squashed version.
Now, I can't just scale the x-coordinate of the nearest point on the unsquashed-circle--that results in a point that slips towards the vertical ends of the squashed circle.
However, it seems to me that the correct point might be found by taking the vector between the centre of the circle and the closest point on the unsquashed circle, and reducing it. That is, that vector should pass through both the unsquashed and the squashed circle, and I think that the point at which it passes through the squashed circle is the point that I want. The vector to the point on the squashed circle should be shorter in general than the vector on the unsquashed circle, and so it should be just a matter of reducing the vector on the unsquashed circle by the appropriate amount.
And here, then, is the point at which I'm finding myself stuck: I don't know by how much to reduce the vector.
When the closest point lies on the x-axis, the reduction should be, I believe: circle_radius * (1 - squashingScalar)
. And naturally, when the closest point lies on the y-axis, the reduction should be zero.
But as to how it varies in-between… I don't know.
I've tried a few options, in particular the use of sine (specifically, 1 - sin(angleOfVector) * (1 - squashingScalar)
, and some variations). This produces the correct results for the point lying on the x-axis and the point lying on the y-axis--but not in-between.
Being stumped, I thus come here for suggestions--does anyone know the proper reduction of the vector in question?