• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 925
  • Last Modified:

X,Y Coordinate value after rotation

I'm placing some text via PHP, C#, and VB applications onto a PDF.  The text position is based on a X,Y matrix with the lower left of the page being 0,0.

What I'm trying to calculate is where the end of the text string is when it is rotated, so I can add more text to it.

I do know the following works, but I need a formula to calculate all angles/rotations.

If the rotation is 0 degrees:
X = X + "width of string"
Y = Y

If the rotation is 90 degrees:
X = X
Y = Y + "width of string"

If the rotation is 180 degrees:
X = X - "width of string"
Y = Y

If the rotation is 270 degrees:
X = X
Y = Y - "width of string"
0
CtrlAltDl
Asked:
CtrlAltDl
  • 3
  • 2
1 Solution
 
CtrlAltDlAuthor Commented:
By the way, rotation is counter-clockwise and at zero degrees text is left to right.
0
 
ozoCommented:
X = X + cos(rotation)*"width of string"
Y = Y + sin(rotation)*"width of string"
0
 
CtrlAltDlAuthor Commented:
That isn't working for me.

Let's say:
X = 1
Y = 2
intStrWidth = 4  (this is my width of string)
r = 0 (this is rotation)

You formula comes out correct if r=0, but if it is anything else it isn't working.

If r = 90 your formula returns:
X = -0.79
Y = 5.57
but it should return:
X = 1
Y = 6

Anymore thoughts?
0
 
ozoCommented:
If r is in degrees, and your sin and cos functions are in radians, then rotation=r*pi/180
0
 
CtrlAltDlAuthor Commented:
That works!  I spent half the day trying to figure that out and I wasn't even close.  Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now