I'm looking to sample from a texture along a circular arc in a fragment shader. That kind of rules out recursive methods such as this.
I have come up with a few different ways to accomplish this: Two that seem the most reasonable are (Given start position p
, center c
, radius r = length(c-p)
, angle (arc extent) theta
in radians and N
positions):
1) Rotate the vector p-c about c by theta/N
, N
times: This requires the construction of a rotation matrix which will be repeatedly used: cost is two trig functions, N
2x2 matrix multiplies, N
or so vector subtractions
2) Find the chord length of one segment traversing a sector: Its length is 2*r*sin(theta/2)
. Once I have the first vector I can rotate it and add it to the previous position to "step along" my arc. The problem with this method is that I still don't know the expression to obtain the orientation of my length 2*r*sin(theta/2)
vector. Even if I did I'd likely need trig functions to construct it. I still need to rotate it so that might require me to still build a rotation matrix. Ugh.
Are there other methods I could consider?