Itay's, solution is elegant and does not require much mat.
You could however go for a more naive(CPU heavy) implementation:
make your line into a array of points and then measure the distance from each point to the center of your circle:
Method to transform two points into a array of coordinates(I have only tested this method briefly)
public static Point[] generatePath(int startX, int startY, int endX, int endY) {
_deltaX = Math.Abs(endX - startX);
_deltaY = Math.Abs(endY - startY);
if ( _deltaX >=_deltaY ) {
//x is independent variable
_numpixels = _deltaX + 1;
_d = (2 * _deltaY) - _deltaY;
_dinc1 = _deltaY << 1;
_dinc2 = (_deltaY - _deltaX) << 1;
_xinc1 = 1;
_xinc2 = 1;
_yinc1 = 0;
_yinc2 = 1;
} else {
//y is independent variable
_numpixels = _deltaY + 1;
_d = (2 * _deltaX) - _deltaY;
_dinc1 = _deltaX << 1;
_dinc2 = (_deltaX - _deltaY) << 1;
_xinc1 = 0;
_xinc2 = 1;
_yinc1 = 1;
_yinc2 = 1;
}
// Make sure x and y move in the right directions
if ( startX > endX ) {
_xinc1 = -_xinc1;
_xinc2 = -_xinc2;
}
if ( startY > endY ) {
_yinc1 = -_yinc1;
_yinc2 = -_yinc2;
}
_x = startX;
_y = startY;
Point[] returnPath = new Point[_numpixels];
for ( int i = 0;i < _numpixels;i++ ) {
returnPath[i].X =_x;
returnPath[i].Y =_y;
if ( _d < 0 ) {
_d = _d + _dinc1;
_x = _x + _xinc1;
_y = _y + _yinc1;
} else {
_d = _d + _dinc2;
_x = _x + _xinc2;
_y = _y + _yinc2;
}
}
return returnPath;
}
Method to calculate distance from center of your circle to every point in your line:
public static double GetLenghtBetweenPoints(Point Source, Point Distination) {
return Math.Sqrt((Math.Pow((Source.X-Distination.X), 2) + Math.Pow((Source.Y-Distination.Y), 2)));
}