Intersection of the line segments vs hitTest

I am trying to improve the hitTest() function.

I have a game in development that involves robots square, rectangular wall and blows of line segment turning forms and move. Without rotation, hitTest works fine, but with the rotation, problems arise.

Rotation 0 and square walls robots work very well. There is a small amount of funkyness with a robot rotated by a corner of the wall, but it is not very sensitive.

The big problem is the collision of two rotated square robots.

Can I create a function to get the segments of line that make up each robot and verification to see if all intersect. This means finding the location of eight points (using height and width and some trig to deal with rotation), find the slope of eight lines and then by testing lines up to 16 times. It would be necessary to find the intersection of each pair of robots. These are the worst numbers, some colisions can be detected or removed before that time the algorithm, but this review will be performed each image on all the robots and the walls and shots (shots might be a single line segment, however)

Right now I'm talking about 8 robots max, maybe the walls of perhaps 5-80, 6-20 shots on screen @ 30 fps.

It is fairly easy to create, but before I spend a day code all this, I wonder if computing requirements will make it prohibitive.

(If so, I'll probably have to move to the circular robots)

I feel that there should be a simple formula to find if two rectangles on a Cartesian plane intersect, but I can't find one.

You can use a base shape hittest.  gskinner has one that it is made public, or, you can create your own using the class' of bitmapdata hittest.

Tags: Adobe Animate

Similar Questions

  • Cannot be joined lines when using the line Segment tool

    So unfortunately, I've updated to the latest version of Illustrator Cc (V19.2.1). And to my horror, I can no longer draw a line (with the line segment tool) then draw another line, coming from the previous those anchor point. When I try to shoot immediately. He's trying to turn the line rather than create a line joining... anyway to change that or am I stuck with it?

    (Also, I use windows currently..)

    http://Tinypic.com/player.php?v=iqc0mc & s = 9 #. Vr5gifJ95hE

    I don't know if you can say/see/see in the video, but here's the process that I'm following departure using the line-drawing the line-> > segment trying to draw a line from that anchor point (and that is the question, when I'm doing it automatically, it assumes I want to transform the line)-> changes to the tool selection and clicks on the line to deselect-> goes back and finishes object, repeating the process.

    Help me please... I'm desperate...

    It is these new life forms, a few disadvantages too with the rectangle tool, ellipse etc. tool.

    to go back to the old behavior

    Object > shape > expand the form, do a deed for him, or do what I did a hotkey (Windows 7).

    Edit > keyboard shortcuts > Menu commands > object > shape > expand the form , then in the first box to the right click in it, select and press a key on the keyboard, I choose F9, OK and name.

    It's an extra step, having to have a finger on the mouse and the other on the keyboard for each line. but I can't think otherwise.

  • How to draw a line (with the line segment tool) then draw another line, from those previous anchor point. When I try immediately draw another line on the other anchor lines it try to turn instead.

    I'm following a course of basic fundamental illustrator on Lynda. The video of "draw straight lines" is troubling me. They draw a line with the line segment and then draw another line coming out the anchor point at an angle.

    Here's where it is troubling me - when I try to drag a line to the anchor point trying to transform the first line, I drew. (the line cursor turns into a selection tool) I can't draw another line connecting the first.

    Advice would be great because it's driving crazy me.

    See you soon,.
    Kyle

    Yes, it is irritating. You must clear the previous line first. If you want to make sure that both ends are perfectly aligned, start by turning on the guides. If you want two lines to be part of the same way, you should use the tool pen instead.

  • Now shift isn't snapping line when you use the line Segment tool

    I could be wrong and it has always been like that, but when I take a shift to rotate a line created by using the line Segment tool turns is more degrees as I thought that it used to. I checked and it works always with the Rectangle tool, but not when I traced a line. Guides and snap to Point are both on.

    Is much more annoying when I'm dragging an end point and it will remain at an ideal level of 90 or 45 angle... but nevertheless it remains valid this angle when I paint, just do not change.

    Matt,

    You are not alone.

    See this thread with a link to the other thread:

    https://forums.Adobe.com/message/8274663#8274663

  • Point of intersection between the line interpolated in Grapher

    How to find the point of intersection between interpolated lines using points offered as input to a file in grapher comps?

    What version of Mac OS X?

  • Drawing with the pen tool or the line Segment tool

    Hello

    I have need of tips and tricks to draw the design of a singlet. What is the way most appropriate for the task? What should I draw the line one by one, or create a model brush to draw? Please refer to the image as an attachment for a better understanding. Thanks in advance.

    draw.jpg

    There is a lot to address the issue. Myself, I will draw all the basic shapes with the pen and shape tools (there really only 5 different forms in the main design), application of rounded corners effect according to the needs and duplication/reflection needed to reproduce the layout. So I "would make the cuts" on the forms by using additional objects... many positioned with step & repeat and/or mixture... and apply Pathfinder operations.

  • Points of intersection of the lines

    Hi guys, I have a little problem. I have two sets of points, which sets two rectangles. I need to know what area they share. No idea how to do?

    I found "Polygon Area.vi" function. but I need points of intersection of these two rectangles to compute the inner area for this function.

    Thanks for any advice.

    I just did a quick check and did not see the convex polygon in LV 2011 VI of Intersection.

    It shouldn't be too hard to write your own.  You need to consider several possible cases: polygons do not intersect.  Polygons have exactly one thing in common (one is on an edge or one vertex on the other). Polygons have in common the segments in one or more edges. A polygon is completely contianied in the other. And if you showed polygons overlap but do not share an edge or a vertex.  If the polygons can be concave, additional complexity might be involved.

    Some simple analytic geometry will allow you to locate the intersection of two straight lines formed by the edges of the polygons. You must then determine if the intersections are on the edge or outside the polygon. Once you have found the 4 (or zero) points of intersection which are relevant, you can use the Poylgon Area.vi, which is in LV 2011, to calculate the desired area.

    Since you're using the student Edition, this is a school assignment?  If so, most of the participants on the Forums will not do your work for you because you don't learn something like that, but we'll help you learn LV

    The steps I would take are: 1. define the case of polygons possible in your situation. 2 analytical hand geometry to make you understand the issues. 3. set the program, with possibly a flow chart or a diagram of the State, with regard to points 1 and 2. 4. write code to implement 3 LabVIEW.

    Lynn

  • extend the line segments

    I drew a line between 2 intersections segment. Can I extend this segment beyond the intersection, as it always goes through them?

    TIA

    Steven

    Steven,

    You should be able to select (with the selection tool is normal if it is a separate path with the direct Selection tool, if it is part of a path with multiple segments) and intensify; You can use the object > transform > scale or change value W or H in the palette/Panel processing, do not forget to Ctrl / Cmd + enter and be the central reference Point is TICKING; in both cases have Edit > preferences > General > Strokes & effects of unchecked scale.

  • Line Segment tool does not select the last line! Why? CC 2015

    I regularly draw several segments on the right with the line Segment tool, then convert them to a live paint. This often requires that lines are tangent or overlapping. In CC 2015 the last segment of the line remains active and the line segment tool switches to a tool "to rotate/move", by drawing a line tangent or closely placed impossible without '' if. '' How can I disable this 'new' and return to the line Segment tool I like in CS 5? Yes, I am trying to embrace the new, he does not cease of themselves in the way of productivity.

    You can not turn it off. Ask us for an option you can disable 'Keep selected', as you can for a brush.

    Feature requests are CC 2015 in the Help menu.

  • Why the Illustrator line segment tool cannot do a.5 pt?

    Why the Illustrator line segment tool cannot do a.5 pt? When I create a line at 90 ° or 180 ° I can't do the thinner than PT race. 1, even if I create the line first and then try to change his race. When I create a line at any other angle I can make the thickness of line I want to by changing the line weight. What I want is to make the line segments which sont.25 ou.5 pts, but least Illustrator will do is pt 1 even if I select the line or rectangle and try to change a.5 ou.25 pt. This same problem exists with the rectangle tool when I create a rectangle oriented at 90 ° or 180 °, but if I rotate the same rectangle what whatsoever other than 90 ° or 180 ° I have then the possibility to change the thickness less than 1 pt. Any ideas what's happening?

    Select all the objects and in the Panel processing uncheck snap to grid of pixels. Also if you want, uncheck this option for new objects in the transformation Panel menu.

  • How can I find several intersect between the number of lines

    Hello

    I created the table as below,

    CREATE TABLE "TRANS" (NUMBER (9.0) "TIDSET", "ITEM" NUMBER (9.0)); "."

    and insert valuse Trans table as below,

    insert into values trans (1,1) insert into values trans (1,3) insert into values trans (1.4); insert into values of trans (1.5); insert into trans values (1.6);
    insert into values trans (2.1); insert into values trans (2.2); insert into values trans (2, 4); insert into values trans (2,6), trans insert values (3,1);
    insert into values trans (3,2) insert into values trans (3.3) insert into values trans (3.6); insert into values trans (1, 2); insert into trans values (1,1);

    and now I have to find the intersection between the lines as below,

    Select tidset from whose point trans = 1
    intersect
    Select tidset in the point transwhere = 2
    intersect
    Select tidset from trans whose point = 3;

    If we have 1000 lines there is no way to find the intersect in this way, so I need to write a program to find the intersect as above without inserting the (item = N) manually each time, can you help me with this please?

    Thank you

    Hello

    user11309581 wrote:
    ... and now I need to find the intersection between the lines as below,

    Select tidset from whose point trans = 1
    intersect
    Select tidset in the point transwhere = 2
    intersect
    Select tidset from trans whose point = 3;

    If we have 1000 lines there is no way to find the intersect in this way,

    This is not true. The query you posted will work well for any number of lines. Perhaps you are really worried about the number of distinct values of the point.

    so I need to write a program to find the intersect as above without inserting the (item = N) manually each time, can you help me with this please?

    In a solution of Ivan, you probably mean "COUNT (DISTINCT point)" rather than "COUNT (*).
    In addition, if element values are predictable, you don't have to code in all hard; You can generate, like this:

    SELECT       tidset
    FROM       trans
    WHERE       item      IN (
                   SELECT     LEVEL
                   FROM     dual
                   CONNECT BY     LEVEL <= n
                 )
    GROUP BY  tidset
    HAVING       COUNT (DISTINCT item)     = n
    ;
    
  • Convert a line segment to a line of pen

    I have a problem with several illustrator files that I get from my students. We use Illustrator to cute objects and some students using the line segment tool to create lines. These lines look like simple lines in illustrator, but after importation in our cute (lasermate v5) software, they become rectangular forms. My quenstion is, if there is a tool or a way to convert these forms in individual lines/box lines.

    I hope that makes sense, English is not my native language

    Knipsel illustrator.JPGKnipsel lasermate.JPG

    I have a solution. When I save my file and check the box "keep transparency" all lines remain simple lines.

  • Anchor points of line Segment

    I want to draw with the line segment tool.  When I want to add a line segment to another segment of line an anchor usually shows upward I know the lines are intertwined with precision.  For some reason any anchor point is not underlined, and the lines are intertwined with precision.  Do I have to activate this feature somewhere?

    funwithphi,

    This looks like a tick toggle view > comments (Ctrl / Cmd + U). You had a mishit keyboard.

  • Why can't I apply a gradient fill to a line segment?

    I created a line segment using the line segment tool. Then I changed the brush in arrow. I select the arrow and and drag the gradient shade I want to the described area to change, but it just turns black. I am able to change the arrow to any solid color, but not gradients. I have attached a photo if this will help. Sorry if this is not clear at all. Any help is appreciated!Screen Shot 2014-06-06 at 3.42.29 PM.png

    I would say just to develop the arrow, and then fill, but that's just me.

  • Line segment tool design everywhere - why?

    With the help of Illustrator CS6 on a MacBook Pro.  Very strange behavior of the line segment tool - when I click and do slip, I don't get a segment of the place where I started at the point where I finished.  Instead, I get several line segments, each with one end where the then slide began it and the other left ends in a trail that runs through every point I did drag the mouse through.  (It's easier to show than to describe.  (See below.)

    The polygon tool works normally.  Therefore, the spiral tool and the pen tool.  But the line segment tool, arc tool, polar grid tool and tool grille rectangular all make this "creeping" effect - very annoying.

    How can I stop this from happening?

    Here is a picture showing what I mean:

    Screen Shot 2013-11-08 at 5.01.03 PM.png

    (It's actually a pretty cool effect if that's what I wanted, but it is not.)

    MWildcard wrote:

    ... No, my tilde key seems fine.  Any other ideas?

    That's the problem, Illustrator think you press the tilde key, doesn't matter if you're not or if the key is fine. Apparently something is not very good with the entrance of this key in Illustrator that could be attributed entirely to Illustrator but in any case the diagnosis should be in this direction and Steve's suggestion is a good first step.

Maybe you are looking for

  • Display of recorder in Signal Express

    I want to display a chart of tape display a signal from slow speed (f = 0.25 to 1.0 hz) signal that represents the position that results in a resistive (1 k) position linear tranducer (IE Unimeasure LX - PA series).  This view must move left as new s

  • G6-1294sl drivers win8

    Hello... I'm sorry for this post, but I can't find my drivers for this model of laptop. I just installed windows 8 [64]. in the section driver hp they don't give me info on this model of laptop... guys help me please? G6-1294SL A8S38EA #ABZ

  • CoverageInfo.isCoverageSufficient (CoverageInfo.COVERAGE_MDS) always returns false on Simulator

    Hello world In my application, I would like to send data on a certain interval using the BES (MDS).  When the Blackberry is on the cover, I send the data right away... but when the Blackberry is out of coverage, I'm storing data on the PersistentStor

  • What active HP-printers making ad hoc network Airprint support?

    I want to buy a printer/scanner for my mother who uses an iPad 2 with 3G connection. It doesn't have Wifi. There are now several printers that support the ad hoc network so that the Ipad could directly connect to the printer and print via Airprint. F

  • BlackBerry App BlackBerry ID

    I have a problem with my BlackBerry id I have syncd my calendar to my Q10 and everything went well. I then started to get guests to check my BlackBerry ID password. I tried to do and got a message saying I could not use this password on this device a