Rotating a Signature: Part 2

I know the center point and I need to rotate every point of the signature around the center point as the centerline rotates. I established the center point in this blog post.

image

Replacing the black dots with some letters, I have this:

image

Where Line AC is the same distance as Line A’C.  They are 2 points on a circle around C with the line as the radius:

image

In addition, you can drop a vertical line from A until its Y equals the Y in the center line.  The distance between LineAB is then known – the difference in Y from the center line that shares the same X Coordinate.

image

Now that the length of LineAC and LineAB is known, the LineBC can be calculated using the Pythagoram theorem.

Then, the A can be moved along its arc with LineAB and LineBC kept constant.  The rotation stops when the Y of Point B is equal to the Y of the horizontal line.

image

 

At least, that it what I think.  I started with a simple test for the distance:

[TestMethod()]
[DeploymentItem("Tff.Signature.Comparison.dll")]
public void GetDistanceBetweenTwoPoints_SamePoints_ReturnsZero()
{
    ScatterplotComparisonFactory_Accessor target = new ScatterplotComparisonFactory_Accessor();
    Point pointOne = new Point(1, 1);
    Point pointTwo = new Point(1, 1);
    Double expected = 0.0;
    Double actual = target.GetDistanceBetweenTwoPoints(pointOne, pointTwo);
    Assert.AreEqual(expected, actual);
}

I then wrote my function:

private Double GetDistanceBetweenTwoPoints(Point pointOne, Point pointTwo)
{
    Int32 differenceBetweenXs = pointOne.X - pointTwo.X;
    Int32 differentBetweenYs = pointOne.Y - pointTwo.Y;
    Double differenceBetweenXsSquared = differenceBetweenXs * differenceBetweenXs;
    Double differentBetweenYsSquared = differentBetweenYs * differentBetweenYs;
    Double SumOfXandYSquared = differenceBetweenXsSquared + differentBetweenYsSquared;
    return Math.Sqrt(SumOfXandYSquared);
}

It ran green so I added some additional tests – and they were also green to go

[TestMethod()]
[DeploymentItem("Tff.Signature.Comparison.dll")]
public void GetDistanceBetweenTwoPoints_SameX_ReturnsExpected()
{
    ScatterplotComparisonFactory_Accessor target = new ScatterplotComparisonFactory_Accessor();
    Point pointOne = new Point(1, 1);
    Point pointTwo = new Point(1, 2);
    Double expected = 1.0;
    Double actual = target.GetDistanceBetweenTwoPoints(pointOne, pointTwo);
    Assert.AreEqual(expected, actual);
}

[TestMethod()]
[DeploymentItem("Tff.Signature.Comparison.dll")]
public void GetDistanceBetweenTwoPoints_DifferentXAndY_ReturnsExpected()
{
    ScatterplotComparisonFactory_Accessor target = new ScatterplotComparisonFactory_Accessor();
    Point pointOne = new Point(1, 4);
    Point pointTwo = new Point(4, 0);
    Double expected = 5.0;
    Double actual = target.GetDistanceBetweenTwoPoints(pointOne, pointTwo);
    Assert.AreEqual(expected, actual);
}

Now that I have AC, I need to calculate AB.  I looked at my test and realized I already have the calculation – all I have to is fine the point on the center line whose Y matches point A’s Y.  That will be the subject of my next post…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: