class HexaPDF::Content::GraphicObject::EndpointArc
def compute_arc_values(x1, y1)
The argument (x1, y1) is the starting point.
Compute the center parameterization from the endpoint parameterization.
def compute_arc_values(x1, y1) x2 = @x y2 = @y rx = @a ry = @b theta = deg_to_rad(@inclination) cos_theta = Math.cos(theta) sin_theta = Math.sin(theta) # F.6.5.1 x1p = (x1 - x2) / 2.0 * cos_theta + (y1 - y2) / 2.0 * sin_theta y1p = (x1 - x2) / 2.0 * -sin_theta + (y1 - y2) / 2.0 * cos_theta x1ps = x1p**2 y1ps = y1p**2 rxs = rx**2 rys = ry**2 # F.6.6.2 l = x1ps / rxs + y1ps / rys if l > 1 rx *= Math.sqrt(l) ry *= Math.sqrt(l) rxs = rx**2 rys = ry**2 end # F.6.5.2 sqrt = (rxs * rys - rxs * y1ps - rys * x1ps) / (rxs * y1ps + rys * x1ps) sqrt = 0 if sqrt.abs < EPSILON sqrt = Math.sqrt(sqrt) sqrt *= -1 unless @large_arc == @clockwise cxp = sqrt * rx * y1p / ry cyp = - sqrt * ry * x1p / rx # F.6.5.3 cx = cos_theta * cxp - sin_theta * cyp + (x1 + x2) / 2.0 cy = sin_theta * cxp + cos_theta * cyp + (y1 + y2) / 2.0 # F.6.5.5 start_angle = compute_angle_to_x_axis((x1p - cxp), (y1p - cyp)) % 360 # F.6.5.6 (modified bc we just need the end angle) end_angle = compute_angle_to_x_axis((-x1p - cxp), (-y1p - cyp)) % 360 {cx: cx, cy: cy, a: rx, b: ry, start_angle: start_angle, end_angle: end_angle, inclination: @inclination, clockwise: @clockwise, max_curves: @max_curves} end