Skip to content

EndpointToCenterArcParams bug #1246

@thenewvu

Description

@thenewvu

Hello,

This article led me here.

I found a bug in:

//(F.6.5.6)
double delta = svgAngle(
(x1p - cxp)/rX, (y1p - cyp)/rY,
(-x1p - cxp)/rX, (-y1p-cyp)/rY);
delta = Math.Mod(delta, Math.PIf * 2 );
if (!flagS)
delta -= 2 * Math.PIf;
r_ = float2((float)rX,(float)rY);
c = float2((float)cx,(float)cy);
angles = float2((float)theta, (float)delta);

According to the spec (the bold text):

where Δθ is fixed in the range −360° < Δθ < 360° such that:

if fS = 0, then Δθ < 0,

else if fS = 1, then Δθ > 0.

In other words, if fS = 0 and the right side of (eq. 5.6) is greater than 0, then subtract 360°, whereas if fS = 1 and the right side of (eq. 5.6) is less than 0, then add 360°. In all other cases leave it as is.

... the code should be:

    //(F.6.5.6)
    double delta = svgAngle(
        (x1p - cxp)/rX, (y1p - cyp)/rY,
        (-x1p - cxp)/rX, (-y1p-cyp)/rY);
    delta = Math.Mod(delta, Math.PIf * 2 );
    if (flagS && delta < 0)
    {
        delta += 2 * Math.PIf;
    }
    else if (!flagS && delta > 0)
    {
        delta -= 2 * Math.PIf;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions