lengthOfRayUntilIntersect static method
Implementation
static double lengthOfRayUntilIntersect(double theta, Line line) {
/// theta -- angle of ray starting at (0, 0)
/// m, b -- slope and intercept of line
/// x1, y1 -- coordinates of intersection
/// len -- length of ray until it intersects with line
///
/// b + m * x1 = y1
/// len >= 0
/// len * cos(theta) = x1
/// len * sin(theta) = y1
///
///
/// b + m * (len * cos(theta)) = len * sin(theta)
/// b = len * sin(hrad) - m * len * cos(theta)
/// b = len * (sin(hrad) - m * cos(hrad))
/// len = b / (sin(hrad) - m * cos(hrad))
return line.intercept / (math.sin(theta) - line.slope * math.cos(theta));
}