Coordinates of rotated rectangle

I have a rectangle that is rotated by a script.
When outputting the geometric bounds of the rectangle, I get the coordinates of the outside rectangle that is aligned horizontally.
How can I get the actual coordinates of the rotated rectangle?

Here's a basic example of using resolve()
Note: This will only work if your object is (directly) on a page. Generalizing it to work whether it's on a page or a spread is very hard, and I don't have the time right now to break my head over this...
var coord = getPointCoordinates(app.selection[0],AnchorPoint.TOP_LEFT_ANCHOR);
alert(coord);
function getPointCoordinates(obj,anchorPoint){
    var oC = obj.resolve(anchorPoint,CoordinateSpaces.SPREAD_COORDINATES);
    var page = obj.parentPage;
    var pC = page.resolve(anchorPoint,CoordinateSpaces.SPREAD_COORDINATES);
    return [oC[0][0]-pC[0][0],oC[0][1]-pC[0][1]];
HTH
Harbs

Similar Messages

  • How to find out the coordinates of rotated textframe

    Hi All,
    With the help of (idml) itemtransform horizontal / vertical distances and path point arrays, I can find out the coordinates of text frame (x1,y1), (x2,y2), (x3,y3), (x4,y4). If the textframe is rotated then item transform values are getting changed, but the path point array values are same. I can find rotation angle by the matrix [cos(θ) sin(θ) -sin(θ) cos(θ) 0 0], But I could not get the exact coordinates of rotated textframe. The textframes are given below.
    Normal Text frame
    <TextFrame Self="u136" ParentStory="u124" ItemTransform="1 0 0 1 101.72727272727272 -349.41818181818184">
                <Properties>
                    <PathGeometry>
                        <GeometryPathType PathOpen="false">
                            <PathPointArray>
                                <PathPointType Anchor="-101.72727272727272 -46.581818181818164" LeftDirection="-101.72727272727272 -46.581818181818164" RightDirection="-101.72727272727272 -46.581818181818164"/>
                                <PathPointType Anchor="-101.72727272727272 -0.3272727272727103" LeftDirection="-101.72727272727272 -0.3272727272727103" RightDirection="-101.72727272727272 -0.3272727272727103"/>
                                <PathPointType Anchor="115.9090909090909 -0.3272727272727103" LeftDirection="115.9090909090909 -0.3272727272727103" RightDirection="115.9090909090909 -0.3272727272727103"/>
                                <PathPointType Anchor="115.9090909090909 -46.581818181818164" LeftDirection="115.9090909090909 -46.581818181818164" RightDirection="115.9090909090909 -46.581818181818164"/>
                            </PathPointArray>
                        </GeometryPathType>
                    </PathGeometry>
                </Properties>         
    </TextFrame>
    Rotated textframe
    <TextFrame Self="u136" ParentStory="u124" ItemTransform="0 1 -1 0 320.3805483338268 -125.07900895050204">
                <Properties>
                    <PathGeometry>
                        <GeometryPathType PathOpen="false">
                            <PathPointArray>
                                <PathPointType Anchor="-101.72727272727272 -46.581818181818164" LeftDirection="-101.72727272727272 -46.581818181818164" RightDirection="-101.72727272727272 -46.581818181818164"/>
                                <PathPointType Anchor="-101.72727272727272 -0.3272727272727103" LeftDirection="-101.72727272727272 -0.3272727272727103" RightDirection="-101.72727272727272 -0.3272727272727103"/>
                                <PathPointType Anchor="115.9090909090909 -0.3272727272727103" LeftDirection="115.9090909090909 -0.3272727272727103" RightDirection="115.9090909090909 -0.3272727272727103"/>
                                <PathPointType Anchor="115.9090909090909 -46.581818181818164" LeftDirection="115.9090909090909 -46.581818181818164" RightDirection="115.9090909090909 -46.581818181818164"/>
                            </PathPointArray>
                        </GeometryPathType>
                    </PathGeometry>
                </Properties>        
    </TextFrame>
    When I converted the values of rotated textframe in to coordinates and drawn in a screen then  I am not getting the exact position where it drawn in the original.
    Can anyone help me to find out the cordinates of rotated textframe.
    Thanks in advance.

    It seems pretty straightforward to me.
    Your center point is (42.375 mm, 27.458 mm) and your box is 58.417 mm x 28.417mm.
    IDML defines the rectangle by its corners, not its center, so let's find the upper-left corner. Divide the width by two and subtract from the x, same for the height and the y. You get (13.665 mm, 13.2495 mm).
    That is in page coordinates relative to the upper-left corner of the page, we can see from your rulers.
    But IDML coordinates are spread-relative from the center of the spread. Your spread is a single page that is 85 mm x 55 mm.
    So if we translate your upper-left corner, it is (13.665, 13.2495) mm - (85/2, 55/2) => (29.3335 mm, 14.2505mm) in spread-relative coordinates.
    But IDML coordinates are in points, not in mm. So we convert (multiply by 2.835). And we get (83.150 pt, 40.395 pt).
    But that doesn't match up with your IDML file, which has  (-82.650 pt, -39.890pt).
    But look at the difference: (0.500 pt, 0.505 pt). That's really 1/2 point, because your box has a 1-pt border and that gets split evenly across all 4 sides. And there's 0.005 of round-off error, bceause floating point math sucks.
    Any questions?

  • IMAQ ROI rotated rectangle ANGLE calculation

    I am using IMAQ Construct ROI to construct a rotated Rectangle ROI. The resulting contours give coordinated of the top and bottom points of the rectangle before rotation and a fifth number indicate the angle. But can anyone tell me how can i calculate the angle in degree from this value, so that i can calculate the exact points of the rotated rectangle?
    Is there any other method to find the actual coordinates of the 4 edges of the rotated rectangle? My intention is to find some points in between these edge points, which i can calculated with simple trigonometry by knowing the angle of rotation. 
    Thank you in advance,
    Mathew

    The angle of rotation is about the center of the rectangle.  I think the angle is already degrees.  If you calculate the center of the rectangle and subtract it from the corners, you have the coordinates to be rotated.  The easiest way I have found to rotate coordinates is to convert them to a complex number, multiply the complex number by the angle IN RADIANS, then convert back to x, y.  Add the center of the rectangle back to the rotated coordinates and you are done.
    Bruce
    Bruce Ammons
    Ammons Engineering

  • Why rotated rectangle tool can't draw rotated ROI on image?

    I want to use the tool window to draw a rotated rectangle on image, but each time, it seems only draw a rectangle, it can't rotate. Don't know why?
    In Vision Assitant, if I use rotated rectangle tool, it will show like this:
    Using the cross lines in rectangle, I can rotate my ROI, it is OK.
    Run the sample code: C:\Users\Public\Documents\National Instruments\CVI\samples\Vision\2. Functions\Geometric Matching, change     imaqShowToolWindow (FALSE);
    to  imaqShowToolWindow (TRUE); 
    on line 93#. Compile then run. Seems I also can't rotate my ROI, don't know why?
    Please show me? Thank you. 

    Hi,
    You cannot perform action on an overlay. In order to achieve what you want to do, I suggest you to use the ROI property in an image property node. Then just pass your ROI coordinates, the ROI will be updated automatically whenever your coordinates changes. You can drag a ROI this is impossible with an overlay.
    Regards

  • Coordinates of rotated textframe

    With the help of itemtransform horizontal, vertical distance and path point arrays, I can find out the coordinates of text frame (x1,y1), (x2,y2), (x3,y3), (x4,y4). If the textframe is rotated then item transform values are getting changed, but the path point array values are same. I can find rotation angle by the matrix [cos(θ) sin(θ) -sin(θ) cos(θ) 0 0], But I could not get the exact coordinates of rotated textframe. The textframes are given below.
    Normal Text frame
    <TextFrame Self="u136" ParentStory="u124" ItemTransform="1 0 0 1 101.72727272727272 -349.41818181818184">
                <Properties>
                    <PathGeometry>
                        <GeometryPathType PathOpen="false">
                            <PathPointArray>
                                <PathPointType Anchor="-101.72727272727272 -46.581818181818164" LeftDirection="-101.72727272727272 -46.581818181818164" RightDirection="-101.72727272727272 -46.581818181818164"/>
                                <PathPointType Anchor="-101.72727272727272 -0.3272727272727103" LeftDirection="-101.72727272727272 -0.3272727272727103" RightDirection="-101.72727272727272 -0.3272727272727103"/>
                                <PathPointType Anchor="115.9090909090909 -0.3272727272727103" LeftDirection="115.9090909090909 -0.3272727272727103" RightDirection="115.9090909090909 -0.3272727272727103"/>
                                <PathPointType Anchor="115.9090909090909 -46.581818181818164" LeftDirection="115.9090909090909 -46.581818181818164" RightDirection="115.9090909090909 -46.581818181818164"/>
                            </PathPointArray>
                        </GeometryPathType>
                    </PathGeometry>
                </Properties>          
    </TextFrame>
    Rotated textframe
    <TextFrame Self="u136" ParentStory="u124" ItemTransform="0 1 -1 0 320.3805483338268 -125.07900895050204">
                <Properties>
                    <PathGeometry>
                        <GeometryPathType PathOpen="false">
                            <PathPointArray>
                                <PathPointType Anchor="-101.72727272727272 -46.581818181818164" LeftDirection="-101.72727272727272 -46.581818181818164" RightDirection="-101.72727272727272 -46.581818181818164"/>
                                <PathPointType Anchor="-101.72727272727272 -0.3272727272727103" LeftDirection="-101.72727272727272 -0.3272727272727103" RightDirection="-101.72727272727272 -0.3272727272727103"/>
                                <PathPointType Anchor="115.9090909090909 -0.3272727272727103" LeftDirection="115.9090909090909 -0.3272727272727103" RightDirection="115.9090909090909 -0.3272727272727103"/>
                                <PathPointType Anchor="115.9090909090909 -46.581818181818164" LeftDirection="115.9090909090909 -46.581818181818164" RightDirection="115.9090909090909 -46.581818181818164"/>
                            </PathPointArray>
                        </GeometryPathType>
                    </PathGeometry>
                </Properties>         
    </TextFrame>
    Can anyone help me to find out the cordinates of rotated textframe.
    Thanks in advance.

    I suspect you'll do better asking here: http://forums.adobe.com/community/indesign/indesign_sdk

  • Multiplying image to coordinates and rotation

    Hi,
    I was wondering if anyone could help me write a Adobe Illustrator script.
    The script must be able to:
    1. Read a file containing several coordinates (X,Y) and angles.
    2. Select an image (or load an image).
    3. Copy and paste an image to the coordinates and rotate the images by the given angles.
    4. Repeat pasting/rotating until all coordinates are pasted with images.
    The result should be something like the image attached below.
    Can this be possible with an illustrator script?
    Could anyone guide me how I should approach this?
    Could you recommend any online references on programming an illustrator script?
    I don't always have access to Illustrator.
    Many thanks in advance,
    Anthony

    Hi Carlos,
    I have a bit of programming background. I'm familiar with VB, C, C++. I'm a novice on illustrator.
    I attempted at writing quick "copy, paste & rotate" script in javascript, see below. But I need to somehow get the coordinates from another file (a text file).
    Can I use something like this on the Illustrator script?
    http://www.javapractices.com/topic/TopicAction.do?Id=42
    var selectedObjects = app.activeDocument.selection; var topObject = app.activeDocument.selection[0];
    var msgType = "";
    if (app.documents.length>0)
         myselection = app.activeDocument.selection;
         if (myselection.length>0)
    for (var i=0; i<myselection.length; i++) {
         myselection[i].duplicate()
         myselection[i].translate(200,0)
         myselection[i].rotate(13)
         myselection[i].duplicate()
         myselection[i].translate(300,50)
         myselection[i].rotate(50)
         myselection[i].duplicate()
         myselection[i].translate(600,10)
         myselection[i].rotate(45)

  • Moving a rotated rectangle [AS CS5]

    I have a script that moves items from the top half of each page to a new page, essentially like this:
    set mybounds to visible bounds of myitem
    tell myitem to move to myPage1
    tell myitem to move to {item 2 of mybounds, item 1 of mybounds}
    Works great except when the item is a rectangle with rotation applied. In that case, getting the bounds of the rotated item returns the bounds of the item unrotated, but when moving the item, the move to coordinates correspond to the rotated item. (or something like that, I haven't worked out exactly what is going on — rotated items get moved to the wrong spot).
    Can anyone suggest and alternative method of moving to a new page that works for rotated items?

    Im having no problems with rotated objects… Moving to a new containing page will forget the visible bounds and the object will default to 0,0 but I can just re-apply the bounds back to position…
    tell application "Adobe InDesign CS2"
         tell the active document
              tell page 1
                   set ThisBox to the first rectangle
                   set BoxBounds to visible bounds of ThisBox
              end tell
              move ThisBox to page 2
              set visible bounds of ThisBox to BoxBounds
         end tell
    end tell

  • Problem rotating rectangle (selecting corners) after creating with rectangle tool in illustrator

    I'm using the latest CC version of Illustrator. When I draw a rectangle using the rectangle tool, I no longer seem to be able to select the corners to resize the rectangle nor does the cursor turn to a rotate icon when I put the mouse just outside the corner. I know that Ai CC treats rectangles differently now, with the live rectangles and the rounded corner options, and the transform box opening automatically. What I'm wondering, and hoping isn't the case, is whether this is this at the expense of being able to go right in and resize using the just the mouse? I know that there is the  "Object > Shape > Expand" option, but having to do that for every time I draw a rectangle is time-consuming and adds and extra step that was unnecessary before. I saw a tutorial on Lynda where the instructor drew a live rectangle in CC AND was still able to resize it by grabbing the corner "handle". Anyone know if this is just a setting I need to turn on or something similarly easy, or is it a case of Adobe inadvertently making the workflow longer when trying to make it easier? And yes, I have "show bounding box" selected under VIEW.

    MOD indi-go girl,
    I am afraid you have come across the Live Rectangle bug which is limited to the MAC versions starting with 10.7 and 10.8, but not 10.9 (Mavericks) or 10.10 (Yosemite). Hopefully, the bug will be fixed soon.
    So a switch to Mavericks or Yosemite with a reinstallation might be the way to solve it here and now.
    To get round it in each case, it is possible to Expand the Live Rectangles to get normal old fashioned rectangles, or to Pathfinder>Unite, or to use the Scale Tool or the Free Transform Tool.
    A more permanent way round that is to create normal old fashioned rectangles, after running the free script created by Pawel, see this thread with download link:
    https://forums.adobe.com/thread/1587587

  • How to obtain corner points of rotated rectangle?

    Am drawing a rectangle, then using an Affine Transform to rotate the angle. After rotating and drawing the rectangle, I need to obtain the 4 corner points of the rectangle. This is (psuedocode) for what I've tried:
    Rectangle r = new Rectangle (x, y, width, height);
    AffineTransform at = new AffineTransform();
    at.rotate (angleInDegrees*Math.PI/180);
    Shape s = at.createTransformedShape (r);
    PathIterator pi = s.getPathIterator(at);
    while (pi.isDone() == false)
    fetchCornerPoint (pi);
    pi.next();
    g2.draw(s);
    The shape is being correctly drawn on the screen, so I know the transofmr is working. But the path appears to contain the 4 corner points of the rectangle prior to rotation, not the 4 corner points after the rotation.
    It's got to be a "doh moment", but I can't see it.

    I notice you call getPathIterator on 's', which is already transformed. I have not verified this, but maybe you should call getPathIterator(at) on the original shape ('r')?

  • CompareTo for two boxes(rotated rectangles)

    I basically have a bunch of cubes in two point perspective that need to be drawn to the screen. I have all of the points calculated in an array for each cube, but I only need the first four points(bottom of the box) to actually tell if its front or not. The bottom of the cubes never overlap thanks to collision detection. What I am trying to do is create a compareTo method in the class that will always put the box that is in front later in an array, so it will be drawn to the screen after the one behind it. All of the cubes are below the horizon line
    [Program full screen|http://img.photobucket.com/albums/v148/jakster4u/1-2.jpg]
    [Example overlapping|http://img.photobucket.com/albums/v148/jakster4u/3.jpg]
    This is what I have so far but it only works some of the time and I was hoping their was a more elegant way than adding more if statements.
    The point at 0 in the array would be the lower point of the bottom, 1 the right point of the bottom, 2 the left point of the bottom, 3 the upper point of the bottom.
    public int compareTo(Object that)
             if(that instanceof IsoBox)
                  //same point
                  if(this.points[0][0]==((IsoBox)that).points[0][0] && this.points[0][1]==((IsoBox)that).points[0][1])
                       return 0;
                  //left of point less than y
                  if(this.points[1][0]<((IsoBox)that).points[0][0] && this.points[1][1]>((IsoBox)that).points[2][1])
                       return 1;
                  //right of point and less than y
                  if(this.points[1][0]>((IsoBox)that).points[0][0] && this.points[2][1]>((IsoBox)that).points[1][1])
                       return 1;     
                  return -1;
             return -1;
        } [Base that needs comparing|http://mad.printf.net/Perspective/PerspectiveDiagrams/PerspectiveDiagram2.jpg]
    I'm doing this for fun so any help or suggestions would be welcome.
    Also all of the boxes are placed randomly, with random sizes using collision detection at the start. A player can move the clear box around the other cubes, and fire bullets off the of the other cubes.
    [Bullets!|http://img.photobucket.com/albums/v148/jakster4u/2.jpg]

    Looking at your examples it appears to me that your code doesn't implement the concept of depth--Z axis or sometimes referred to as "point of view". you will need to do so to reliably get overlap consistency.

  • Probleme rotation coordinate

    Hi everybody,
    I`m going to try to be clear, but I have juste one problem with the coordinate about a rotate rectangle.
    So, first I have this data, and when I put in Excel I have a right rectangle.
    SO now I know that I have to modify the data with the rotation, It`s what I did.
    It worked very well, I tried with graph and to modify the degree of rotation it was perfect I had good rotated rectangle.
    My next step and final step was just to put the coordinate on excel and reproduce the same rectangle on one graph in Excel.
    And it`s there that I met the problem.
    I have no Idea why, and I don`t see what to change to fix that......
    I now that just one rotation of 90 degree it`s enough to correct the position but where can I change something?
    If somenody know something about that or have the solution, you`re welcome.
    Sorry about this big post but I think is more clear with picture than more text.
    Thank you again for your answers (in advance)
    Maxime
    Solved!
    Go to Solution.

    Direction of rotation?
    In Excel, it looks like a postive rotation causes it to rotate clockwise.
    I didn't dig into your math, but in a lot of programs (like Autocad), a positive rotation angle is counter clockwise following the right hand rule.  Where 0 is the + X axis and a line from there rotates towards the + Y axis with a + angle.

  • Getting the coordinates of an overlayed rectangle or point

    I have drawn a rectangle or point on an image using the Tools and I now want to get the coordinates of the rectangle or point I have just drawn. How do I do this?

    bep -
    To do this, use the Regions property on the CWIMAQViewer object, and assign it into a variable of the type of the ROI (in this case, a rectangle). Here's an example:
    Dim rect As CWIMAQRectangle
    Set rect = CWIMAQViewer1.Regions(1)
    The rect variable should now contain the dimensions of the rectangle drawn.
    Let me know if you have problems with this. Thanks!
    Greg Stoll
    IMAQ R & D
    National Instruments
    Greg Stoll
    LabVIEW R&D

  • 3D rotationX/Y/Z with local coordinate?

    Hi,
    When I use 3D rotation tool, there is an option called global transform, if it turned off, the object would rotate by its own axes, this is exactly what I want. How can I do rotatation like that with AS3 code?
    Is there any property if changed then rotationX/Y/Z would rotate object by its axes?
    Thanks

    Thanks,
    I have found an easier way to do local rotation, so write here for someone needs it in the future:
    + Put the object you want to rotate by local coordinate in a container (make it a symbol again, name it, example cont1 and obj1.
    + If you want to rotate it by local coordinate, then write: cont1.obj1.rotationZ +=1; // it will rotate by local coordinate.
    + If you want to rotate it by global coordinate, then rotate its container, just: cont1.rotationZ +=1;
    Regards

  • Draw rectangle in plot

    How can i draw rectangle in graph
    with Component works++?

    Annotations were introduced to the C++/ActiveX graph in Measurement Studio 6.0. This is the best way to draw a rectangle.
    Details:
    CNiAnnotation:hape is a property of type CNiShape. CNiShape::Type is an enumeration, one value of which is CNiShape::Rectangle. Use CNiShape::XCoordinates and CNiShape::YCoordinates to specify the location and size of the rectangle. Use CNiAnnotation::CoordinateType to specify whether the coordinates of the rectangle are in axis units or in pixels relative to plot area or screen area.
    If you cannot upgrade to Measurement Studio 6.0, you could consider using 2 cursors as a workaround.
    David Rohacek
    National Instruments

  • Get rectangle from pdf C#

    Hi I displaying my a pdf on my form using the Adobe PDF Reader
    Once displayed the user can draw a rectangle using the Selection tool within Adobe
    I would like to know if there is a way i can get the coordinates for the rectangle drawn by the selection tool

    I don’t believe so, no.

Maybe you are looking for

  • New problems importing Pro-res files

    Hi, I am running CC14 on PC (HPz800 Windows 8) - and I have recently become unable to import Pro-res files into After Effects or Media Encoder. These files DO open in premiere I have tried the following: Restarted Cleared my cache Cleared all my appd

  • I need help finishing my assignment

    this is the program public class CableInstallationTestClass { public static void main(String[] args) {   CableInstallationClass  ci = new CableInstallationClass();   ci.setNumOutlets(1);   double subTotal = ((ci.getNumOutlets() -1 ) * ci.getCostPerOu

  • Apple TV 2.0 WILL have Closed Captioning Support

    see article from ilounge. Look at the 3rd picture from the bottom. http://www.ilounge.com/index.php/articles/comments/what-to-expect-from-apple-tv- 20-photos-and-details/ this is good news for a lot of people. Now if apple will add more CC movies to

  • Address book contacts GONE!!!-Please help me

    Please help me as I don't know what's happened to my contacts. I was burning DVD's on an external drive and reading email when Mail crashed. Shortly after that I re-opened Mail and tried to send mail when nothing was coming up for addresses and I wen

  • Deadlock while executing catalog.sql

    I've installed a local DB on my computer, running Oracle 9i. Wanted to import a dump and the manual says first execute the catalog.sql Script. When I do this as sys I get following errors: Execution x: ORA-04045: errors during recompilation/revalidat