Rotation of bounding box ?

I know I can get the transformation info on a sprite to work out the position of a bounding box used for collision detection, but if the image is being rotated, how can I rotate the bounding box for a more accurate collision test.
the image is rectangular so a square(ish) bounding box won't do.

1. Are we operating under the same definition of
"bounding box?" My experience has always been that a
bounding box is the region in which a sprite is
counted as existing for the purpose of collision
detection. I didn't see any collision detection in
that code.
2. If we -are- talking about collision detection, I
will now (after review) agree with you that the
Polygon object doesn't have all of the functionality
needed. However, an object which represents a
bounding polygon could be used quite nicely in this
situation, as it could be freely rotated internally
and fixed to a given point on the sprite.yes, bounding polgons are sometimes used - but the point of bounding rectangles, or bounding circles, is that they are cheap in terms of computation.
calculating in the intersection of 2 polygons is not simple, and not cheap.
Additionally, the most significant content of my post
was the corner detection; no two bounding polygons,
regardless of their orientation, can be intersecting
if none of the corners for either polygon is
contained within the other.yes they can, very easily infact.
not sure how good this is going to look /me tries some ascii art ;]
1
4oox xoo5
ox xo
x x
3xxxxxxx2
6
its 2 triangles {1,2,3} and {4,5,6} arranged to overlay each other (they form a star shape).
>
Am I misunderstood as to the purpose of a bounding
box? Let me know, please. :) Thanks!rob,

Similar Messages

  • Bounding Box Rotation Using AffineTransform

    Hi everyone,
    I'm making a 2D overhead view tank game (lots of those around, hey?). The problem I have is with collision detection using bounding boxes.
    I use the AffineTransform that I rotate the sprite image with to rotate that sprite's bounding box. The problem is that the bounding box doesn't anchor itself to the sprite. Instead, when the tank rotates, the bounding box leaves the sprite and moves alongside it. As you can imagine, this doesn't lead to good collision detection.
    How can I anchor the bounding box to its sprite so that whatever rotation or movement the sprite does, the bounding box stays on the sprite and moves with it?
    The code fragment that deals with rotating the bounding box and drawing it is below.
    tankShape = new Rectangle2D.Double(enemy.getX(), enemy.getY(), enemy.getWidth(), enemy.getHeight());
    at = AffineTransform.getRotateInstance((Math.toRadians(enemy.getAngle())+Math.PI/2),
    (enemy.getX()+11), (enemy.getY()-24));  //+11 and -24 are to anchor the bounding box at the centre of the sprite
    tankShape = at.createTransformedShape(tankShape);
    g.draw(tankShape);Thanks,
    Has

    Note to myself, this is how it's done:
    public void paintHitBoxes(Graphics2D g)
         double x = player.getX();
         double y = player.getY();
         x += Math.cos(Math.toRadians(player.getAngle()));
         y += Math.sin(Math.toRadians(player.getAngle()));
         Rectangle2D.Double tankShape = new Rectangle2D.Double(x, y, player.getWidth(), player.getHeight());
         g.setPaint(Color.red);
         imageLocation =
              AffineTransform.getRotateInstance(Math.toRadians(player.getAngle())+Math.PI/2, x+(player.getWidth()/2), y+(player.getHeight()/2)); //7, 14
    g.draw(imageLocation.createTransformedShape(tankShape));
    }

  • Bounding Box of Triangle

    I am looking for a way I can calculate the bounding box of a triangle?
    For example I have a set of three points and it will return the bounds even if the triangle is rotated.
    I understand that their is a method that you can use built-in but I need to be able to calculate it myself for reasons of my project.
    Kind Regards

    Isn't the bounding rectangle always (minx, miny, maxx, maxy) for any shape?

  • Unwanted bounding box resets

    I'm having a rather infuriating issue with Bounding Box resets.
    Image here:
    http://img848.imageshack.us/i/unled3j.jpg/
    Sorry—I can’t get it to show up in this message.
    The first row of the linked image shows a roughly isometric view of a machine decal, followed by straight on views of a red box and a newer version of the decal.
    To turn this new decal into a similar perspective, I normally:
    1-rotate the decal using the black/closed arrow hovering over a corner handle
    2-use the Free Transform tool on the rotated side handle of the bounding box to skew the rotated image
    The second row shows what happens to the red box and its Bounding Box after rotation.I would normally use the handle that had been the middle right to Free Transform this object
    The third row shows the new decal rotated. It's bounding box has reset itself automatically and is no longer useful with the Free Transform tool.
    These two objects are on the same document, so I'm guessing the Bounding Box reset has something to do with some attribute of the new decal. Whatever it is, an operation that normally take 10 seconds has become suddenly impossible. Anybody know what to do to fix this?
    Thanks.
    Matt
    http://img848.imageshack.us/i/unled3j.jpg/

    I had this problem as well, and it was driving me crazy. This happens when you have multiple objects sellected that have bounding boxes set at different rotations. They can be grouped or ungrouped, it makes no difference, and the bounding box will automatically reset. I found that resetting the bounding box (before applying the transform) fixes the problem. This seems counter intuitive, because the bounding box doesn't look like it needs to be reset. It already appears straight, so there is no noticable change after applying the reset bounding box command. However, afterwards the bounding box will stay in the correctly rotated position because all objects have the same bounding box rotation.

  • I should not have to "expand" a rectangle before resetting its bounding box

    When you create a rectangle and rotate it, the Reset Bounding Box command is available to you, but selecting it does nothing. To get it to work, you have to "expand" the rectangle first, and then select Reset Bounding Box. This is idiotic. If I've explicitly told the program I want to reset the bounding box of said rectangle, and for whatever arcane reason it can only reset the bounding box of "expanded" rectangles, then it should "expand" the dang rectangle for me and reset the bounding box like I asked.

    As it is a Live rectangle and not a Real rectangle it has not been 'really' rotated.
    In the same way when you round its corners they are not 'really' rounded until the thing has been expanded.
    I am still in the same mindset for this.
    Rounded Rectangles should have been changed to live rectangles.
    And the Real Rectangle tool should have left alone.
    We now have a High End Vector Drawing Program without a simple rectangle tool
    I can't work out what the hell they were thinking.
    I'm worried about what the next tool to be broken will be.

  • How to create bounding box over part of path

    Hi,
    need to create a bounding box over part of path as done by Wade ; http://forums.adobe.com/servlet/JiveServlet/showImage/2-4305034-180560/Screen+Shot+2012-03 -31+at+6.01.24+PM.png
    tnx,

    The other two posters are absolutely correct.
    But you have two choices to do what you want as far as I know since your path is not an effect as mine was.
    You can use the scissor tool to cut the segment you want to be able to select. I assume you want to move it or rotate it or perhaps resize it or a combination of those.
    If you need the original path to remain intact you can take the lasso tool and select that segment of the path and do a copy and then a paste in front and you will have a copy of that segment sitting on top of the original segment which will still be part of the original path.
    If you intend to alter the segment and then rejoin it to the original path then use the scissor tool approach.

  • Scopes limited to a bounding box!

    I've put in a wishform request (  https://www.adobe.com/cfusion/mmform/index.cfm?event=processform&name=wishform#wishprodlan g  ) for something that would have a HUGE effect on the speed of my grading: being able to have the scopes limited to the data in a drawn bounding-box! I'd want it to be a key-boarded shortcut, but one you could set to "on" and just leave as you wanted to.
    Think of how this would assist you in  skin-tone corrections/controls, being able to at any moment draw a quick bounding-box and see where on the vector-scope your "skin" falls, both for rotational degree (hue) and saturation!
    Think of the way this could work in checking for secondary corrections ... both in determining IF you need to do the work of making a secondary, and ... if so ... showing you where you need to start AND where you need to go.
    Currently the only way to do this is to make a top-level primary layer, create a mask on it futzing around to make the mask fit exactly the area you need to "see" in the scope, set the layer for controlling the outside of the mask, and then "grade" the outer area to black.
    You need to do all this anytime you want to restrict the scopes to one small section of the image. The control as I've suggested, only because I've learned it is something available in some other software and is slicker than SNOT to use (    ) ... well, it would be available INSTANTLY all the time. What a huge time-saver this would be for me.
    Y'all are welcome to post this on to Adobe also ... 
    Neil

    FWIW Neil
    In my experience ..."skin tone" and any other is ultimately CC and graded to the "eye-ometer"
    Key to subtleties and control  is the use of Secondaries thru HSL qualifiers and masks.
    Personally ..once I get into areas such as skin tone...its all eye and not a glance at a scope ...apart from the constant eye on Black and highlight levels.
    I would like to see Adobe gain scope consistency across the apps.  SG , PPRO and AEFX
    I am not adverse to a "floating point scope" as an optional tool. ( Another scope).
    If you can get a look at DVRack (Serious Magic)  or Adobe On Location scopes... do so.

  • Bounding box area too large for interactive button

    Hello all,
    I am new to InDesign interactive part and I'm creating my first ever interactive file. So the problem is that I have one path (which is a diagonal line basically) made into a button that should work on roll over mode. Now the the bounding box area is so large around it and it will react already when it shouldn't (when the mouse touches the bounding box area).
    Is there a way how to manipulate with the empty bounding box area so it wouldn't react or should everything be made of squares?
    Cheers,
    Egert

    Hey guys, thanks for the replys.
    Bob's idea definately works. I am thinking of creating a line of buttons and then creating a group of them so they should react as "one" button.
    And I just tried Manish-Sharma's thing too and it seems to be helping aswell. The bounding box is way smaller if I draw the button as horizontal as possible and I rotate it once created into a button.
    Thanks guys!

  • Bounding box bug CS6 (Creative Cloud)

    Anyone else have the bounding box occassionally stick to an object? I can select other objects but the bounding box will extend across the artboard from the new object and group the older object with it. I can't click off of the object either. I think it's mainly a text box problem, I can't recall having this problem with shapes or path drawn objects. I just fixed it by isolating it then immediately jumping out of that isolation, it was suddenly unselected. Anyway, just checking in with other users, wanted to catalog this at least.
    EDIT: Just had this happen with a photo in illustrator, as well as a circle I just clicked off from creating. The only hinderance it brings is that scaling, rotating, etc. is directly correlated to both selected objects rather than the one I intend to scale or rotate, etc.

    I've seen this happen on and off since the original CS. On both Mac and Windows systems across several OS versions. Sad to hear it's still with us in CC. I've seen it blamed on all sorts of things; text objects, clipping masks, imbedded / non-imbedded objects, a particular OS, etc. None of which have ever held true in all cases.
    Anyway, one way that (sometimes) solves it is to;
    Create another object, even a small square.
    Align the new object with the 'stuck' one - use any alignment at all. If another object moves, you can immediately undo.
    In any case, once you deselect and delete your dummy object after the align (or align and undo), four times out of five the stuck bounding box is gone (for a while, anyway).
    good luck.
    --OB

  • Bounding Box  and Affineransform

    I'm working on a tank game. right now, i just have an applet and a little tank that drives around. unfortunately, i can't figure out how to get a bounding box to encapsulate with my image. can anyone help me? my prog is two classes: TankGame and Tank. Tank extends Rectangle and draws itself and an image of a tank. as the image is rotated, the rectangle(bounding box) is offset between 0 and image size, along both the x and y axis.
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    public class TankGame extends Applet implements ImageObserver, KeyListener, Runnable{
         int gameSpeed=50;
         int tankSpeed=4;
         Graphics2D dbg;
         Image dbImage, tankPic;
         int imageHeight=32, imageWidth=32;
         Thread th;
         Tank theTank;
         AffineTransform transform;
         boolean forward=false,reverse=false,right=false,left=false;
         Point location;
         double rotation=Math.PI/20,angle=Math.PI;
         public void init ()     {
              setBackground(Color.black);
              setSize(600,600);
              tankPic=getImage(getCodeBase(),"tank.jpg");
              theTank = new Tank(tankPic, this);
              addKeyListener(this);
              transform = new AffineTransform();
              location = new Point(150,150);
              transform.translate(location.x,location.y);
              transform.rotate(angle);
         public void start (){
              th = new Thread (this);
              th.start ();
         public void run ()     {
              Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
              while (true){
                   move();
                   repaint();
                   try     {
                        th.sleep (gameSpeed);
                   }catch (InterruptedException ex){
         public void paint (Graphics2D g)     {
              g.setColor(Color.red);
              theTank.draw(transform, g);
         public void update (Graphics g)     {
              if (dbImage == null){
                   dbImage = createImage (this.getSize().width, this.getSize().height);
                   dbg = (Graphics2D)dbImage.getGraphics();
              dbg.setColor (getBackground ());
              dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);
              dbg.setColor (getForeground());
              paint (dbg);
              g.drawImage (dbImage, 0, 0, this);
         public void keyPressed(KeyEvent e) {
              if (e.getKeyCode()==38){forward=true;}
              if (e.getKeyCode()==40){reverse=true;}
              if (e.getKeyCode()==37){left=true;}
              if (e.getKeyCode()==39){right=true;}
         public void keyReleased(KeyEvent e) {
              if (e.getKeyCode()==38){forward=false;}
               if (e.getKeyCode()==40){reverse=false;}
              if (e.getKeyCode()==37){left=false;}
              if (e.getKeyCode()==39){right=false;}
         public void keyTyped(KeyEvent e)  {}
         public void move(){
              if(forward){transform.translate(0,-tankSpeed);}
              if(reverse){transform.translate(0,tankSpeed);}
              if(left){
                   angle=angle-rotation;
                   transform.rotate(-rotation,imageWidth/2,imageHeight/2);
              if(right){
                   angle=angle+rotation;
                   transform.rotate(rotation,imageWidth/2,imageHeight/2);
              location.y=(int)(transform.getTranslateY());
              location.x=(int)(transform.getTranslateX());
              theTank.moveTo(location);
    /*class tank which draws itself and an image (though not always in the same place)*/
    class Tank extends Rectangle {
         Image image;
         Tank(Image img, ImageObserver obs){
              image=img;
         public void moveTo(Point p){
              setRect((double)p.x,(double)p.y,32,32);
         public void draw(AffineTransform transform,Graphics2D g){
              g.drawImage(image,transform,null);
              g.setColor(Color.blue);
              g.draw(this);
              g.setColor(Color.red);
    }i've messed with this for a couple of hours, this morning to no avail.

    Try this:
    change the tank class to     93 class Tank extends Rectangle {
         94     Image image;
         95
         96     Tank(Image img, ImageObserver obs){
         97         image=img;
         98         setRect(0,0,32,32);
         99     }
        100 /*  public void moveTo(Point p){
        101         setRect((double)p.x,(double)p.y,32,32);
        102     }*/
        103     public void draw(AffineTransform transform,Graphics2D g){
        104         g.drawImage(image,transform,null);
        105         g.setColor(Color.blue);
        106         g.draw(transform.createTransformedShape(this));
        107         g.setColor(Color.red);
        108
        109     }
        110 }and comment out the line that calls the moveTo-method.
    Does it do what you want it do now?

  • Retain bounding box dimensions after reflecting object

    Is there any way of retaining the dimensions of a bounding box after reflecting an object. E.g. if I create a rectangle and rotate it 45 degrees the bounding box is flush with the rectangle around its perimeter. However if I reflect the rectangle vertically at 90 degrees the bounding box is no longer flush with the rectangle and so I cannot scale the rectangle without losing its original dimensions.
    I've tried the reset bounding box option but it doesn't seem to work very well. Is there any way to reflect an object and retain the bounding box perimeter? Thanks.

    Sorry, mistake in my original post. I should have said 30 degrees (or anything other than 45).
    Example. Create a rectangle and then rotate it 30 degrees. Create a copy of the rectangle and then reflect it 90 degrees vertically. The image below illustrates the new (post-reflection) bounding box on the left. The rectangle height cannot be changed without losing the width dimensions and vice versa.
    The second example below illustrates the problem with a stick man created using a number of rounded rectangles.
    The bounding boxes for the reflected stickman (on the left) prevent the limbs from being lengthened correctly.

  • Text put into a canvas element with context.fillText() always has a black box where each letter goes. If the text is black you just see the black rectangle. If the text is not black you see it on the black bounding box. Surely this is not right.

    This has happened on the last few versions of firefox, as long as canvas has been supported. I see other people's screen shots from canvas tutorials, and the text always looks normal. On my system, any text put into a canvas element via context.fillText() will have a black bounding box for each letter, sized appropriately for the letter. If the text is black, of course you only see rectangles. If the text is a contrasting color, then you can read it, but it looks bizarre.

    Thomas...same kind of crap here.
    I used Custom Text - entered a sentence, hit return, entered another.
    Set to 72 pt.
    The default alignment is centred - I want left aligned text...the text start point stays at the centre of frame and the sentence runs off the edge of the bounding box.
    There is no settings in the Text or Title inspector dialog to correct that!
    Using Transform will not sort it!

  • Bounding boxes appear in Acrobat after exporting from InDesign

    Whenever I create outline fonts in my CS3 version of InDesign (I haven't upgraded to CS4 on this one program yet), I'm left with some very strange thin white lines surrounding some or all of the resulting letters that look suspiciously like bounding boxes. This never seems to occur if I don't create outline fonts, but simply embed the fonts and create a PDF using the Export command, so I have to believe the anomaly has something to do with this conversion process within the program. If I use illustrator CS4 to create outline fonts and then place them within my InDesign documents, I don't appear to have the problem. However, that's not a very desirable solution as it negatively impacts the fluidity of layouts and the ease of design, both of which I use in design for.
    And yes, these small thin white lines do print, so the problem is far more than merely academic.
    Has anyone else ever experienced this issue, and if so, how did you solve the problem (assuming you did)?

    Sorry about that, I apparently forgot to attach the file; have done so now.
    The method I'm using for creating outlines is simply to use the "Create Outlines" command under the Type menu within InDesign. Then I create my PDF files by using the Export command under the File menu and choosing the PDF/X1a option. 99% of the time I get perfect results, it's only when I try to make outline type that I encounter this problem. You'll clearly see the artifacts in question in the example attached.
    I don't know whether or not the press would have printed these artifacts, as you suggest, since no printer has been willing to execute a file that shows any anomaly in the proof process. I can't say that I blame them.
    Hopefully you will see what I'm talking about and can recommend a solution, though I like your idea of simply giving them a properly executed file and then telling them to get a life. It hasn't worked so far, as I unfortunately deal with a lot of Neanderthals around here, but I suppose it's worth putting forth again the next time this issue arises. It will.
    By the way, no print house of my choosing is this far behind the curve, if at all. These cavemen are always printers who have long-standing relationships with my clients, and for whatever reason (generally lowest cost I'm sure), the clients think they hung the moon. We, of course, no otherwise, but it does it profit a designer to tell his client he or she is crazy for using a printer who is a decade behind the technology curve.
    We cowboy up and seek solutions, eh?

  • I have 4 equal oblong shape created with borders How do I go about knowing what size the selection area is so that I can crop an image to fit. I don't want to use paste in then adjust the bounding box to suit

    I have 4 equal oblong shape created with borders How do I go about knowing what size the selection area is so that I can crop an image to fit. I don't want to use paste in then adjust the bounding box to suit

    What do you mean a moderator

  • Is there a way to tighten a text bounding box?

    Hey all,
    I've looked before but never found a definitive answer to this question:
    Is there a way to tighten the text bounding box without converting it to outlines?
    I work for a screen printer, and want to figure out a way to tighten the bounding box without changing the leading and without converting it to outlines in order to be able to edit said text. We deal with a lot of clients who send us names, that are often misspelled, and after an initial proof need to be corrected. Sometimes we need to center this text to an object.
    Illustrator's bounding box, unlike that of Corel (which is our primary program, and won't open AI files) includes the leading below the type, so when you center it, it's not visually centered:
    So I guess my real question is is there a way to get the text centered (as seen below) without converting the text to outlines, or messing with the leading, or is there a way to tighten the bounding box?
    Thanks in advance!
    -K

    Combat and Dandreu,
    You may use this silly way:
    1) Tick Edit>Preferences>General>Use Preview Bounds;
    2) Select the Type and Effect>Path>Outline Object.
    That will reduce the Bounding Box to the actual bounds of the letters so you can centre as you wish.
    Remember to untick Edit>Preferences>General>Use Preview Bounds before you get a reverse issue.

Maybe you are looking for

  • Populate PDF template with data from another form

    Hi all, it's been a while since I've been here. I'm not a LC pro by any stretch, but I've been working on a personal project which I hope will someday result in a small business. The idea is simple: a client fills out a custom form in Acrobat Reader

  • ICR - Process 001 and Process 002 Obligatory Group Chart

    Hi, another problem with ICR. I use ICR process in ECC 6.0 version but my client don't use the Group Chart. how can I use ICR processes to riconciliation my company? Can you help me? Thank you very much. Best regards. Giampaolo

  • I would like to use FireWire to move files between 2 iBook G3's.

    I would like to use FireWire to move files between 2 iBook G3's but the disk icon for the target disk computer does not show on the other. I've tried using 3 different iBooks and 2 different Firewire cables. Are there any other settings I should use?

  • [JDev TP3] : Abou ADF Security ?

    i tryed to develop application that mange several (assignment/task/project) and using adf security that cofigure users and roles from database BUT i have for every task same types of roles For Example: i have task A ,task B,task C,..... for every tas

  • Printing two decimal places from BigDecimal values

    I am using BigDecimal to represent money values. My output needs to line up so that (with a non-proportional font) the decimal point and the two decimal places are in the same columns for each line. But when the dollar value has zero cents, or has a