X,Y Coordinate value after rotation

Posted on 2006-05-22
Last Modified: 2006-11-18
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"
Question by:CtrlAltDl
    LVL 14

    Author Comment

    By the way, rotation is counter-clockwise and at zero degrees text is left to right.
    LVL 84

    Expert Comment

    X = X + cos(rotation)*"width of string"
    Y = Y + sin(rotation)*"width of string"
    LVL 14

    Author Comment

    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?
    LVL 84

    Accepted Solution

    If r is in degrees, and your sin and cos functions are in radians, then rotation=r*pi/180
    LVL 14

    Author Comment

    That works!  I spent half the day trying to figure that out and I wasn't even close.  Thanks!

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Complex Numbers are funny things.  Many people have a basic understanding of them, some a more advanced.  The confusion usually arises when that pesky i (or j for Electrical Engineers) appears and understanding the meaning of a square root of a nega…
    Article by: Nicole
    This is a research brief on the potential colonization of humans on Mars.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now