I two concentric circles on the screen and I want the circle on the inside to move around while the user drags their finger around the outside of the larger circle. This means that I have two point, center of the larger circle and the point at which the user touched. How do I calculate where the center of the smaller circle should be?
Share
Ok, if you’re drawing a persons eyes it is a completely different matter.
If we start with the following values
re: the radius of the eyerp: the radius of the pupilp1 = (x1, y1): the coordinates ofthe center of the eye
p2 = (x2, y2): the coordinates ofthe users touch
v1 = [x3; y3]: the direction vector betweenp1andp2.x3 = (x1 - x2)y3 = (y1 - y2)l = sqrt((x3)^2 + (y3)^2): the length ofv1Then do the following steps
re - rpof the middle of the eye (i.e.l < (re - rp)), it he/she is draw the pupil atp2and do no more.xcoordinate(re - rp) * x3 / l + x1andycoordinate(re - rp) * y3 / l + y1If you have more than one eye, just repeat the steps for the other ones.
I certainly hope you understand what I mean by this, if you don’t just ask away.