[quote=215506:@Will Shank]Oh, now your calculation of origin makes sense. So a rectangle 200 wide, 100 tall, top-left at 0, and 0 rotation looks like this…

AnchorPoint is <0.4, 0.3> and marked in purple with a line to the top-left corner. Then changing the top-left from <0,0> to <70,-120> looks like this…

Now changing the rotation angle to 1 (in radians) looks like this, where the blue dot is the point you want to calculate and the grey dot is the unrotated top-left point…

I worked out these 2 methods that calculate the blue point

[code]Function topLeft(obj As VectorObject) As Point

dim ax, ay, radius, angle, x, y As double

ax = obj.width * obj.AnchorPoint.x

ay = obj.height * obj.AnchorPoint.y

radius = Sqrt(ax * ax + ay * ay)

angle = ATan2(ay, ax) + obj.angleRadians

x = obj.left + ax - radius * cos(angle)

y = obj.top + ay - radius * sin(angle)

return new Point(x, y)

End Function

Function topLeft(obj As VectorObject) As Point

dim ax, ay, sina, cosa, x, y As double

ax = obj.width * obj.AnchorPoint.x

ay = obj.height * obj.AnchorPoint.y

cosa = cos(obj.angleRadians)

sina = sin(obj.angleRadians)

x = -ax * cosa - -ay * sina

y = -ax * sina + -ay * cosa

return new Point(obj.left+ax+x, obj.top+ay+y)

End Function[/code]

This last one is very similar to yours and I think changing your x1, y1 lines to this would be equivalent… (the negatives are left to be factored out)

```
x1 = obj.Left + origin.x + ( -origin.x * cos - -origin.y * sin )
y1 = obj.Top + origin.y + ( -origin.x * sin + -origin.y * cos )
```

Also, this is working for positive Y going down orientation (positive rotation is clockwise). I think it works for Y-up orientation too but not sure.[/quote]

Thankyou very much. You have been very helpful. I have attempted to study into the maths behind this and I have used that to alter it so that it supports TopRight, BottomRight, etc.

One small issue I have ran into is the points seems slightly off. I was wondering if this looks like it has anything to do with the rendering system I have used or if this is a small flaw in my modified version of the method. I also do not understand why with ATan2, the coordinates are swapped. I would expected x, y not y, x.

I am fine with this now but just wanted to get better understanding or see if the algorithm has any significant flaws.

```
Function TopLeft(obj As VectorObject, addX as double = 0, addY as double = 0) As Point
dim ax, ay, aax, aay, radius, angle, x, y as double
//set point to anchor around
ax = obj.AnchorAbsoluteX
ay = obj.AnchorAbsoluteY
//calculate the anchor position with added relative position
aax = ax - addX
aay = ay - addY
//calculate length of line from 0, 0 to absolute anchor position with added relative position
radius = Sqrt((aax * aax) + (aay * aay))
//calculate angle based on were the line just meets the anchor point and add the applied rotation from anchor with added relative position
angle = ATan2(aay, aax) + obj.Angle.Radians
x = (obj.left + ax) - (radius * cos(angle))
y = (obj.top + ay) - (radius * sin(angle))
return new Point(x, y)
End Function
```