gabrielslo...@gmail.com wrote:
Hey, supose i have a Rect and a Line, i just want to see if the line
intercepts the rect, is that possible somehow in a kind of optimized way
For axis-aligned rectangles you probably want the Cohen-Sutherland
algorithm:
https://en.wikipedia.org/wiki/Cohen%E2%80%9
Shapely (http://toblerity.org/shapely/manual.html ) is a Python library
with functions for things like 'do these two shapes intersect?' I don't
know if building the Shapely objects is quick enough to be done during a
game, but it's worth a try.
On 18 November 2017 at 18:55, bw wrote:
> It seems
It seems so simple a problem to our eyes. But it's computationally a
non-trivial problem. You can find algorithms on the web mostly in other
languages and convert them to Python, like I did here.
https://bitbucket.org/gummbum/gummworld2/src/200e9350acca33d40b0c41c9e74c0eaeb6079061/gamelib/gummw
A central key in the whole task is gaining good control over which of
>, <, <=, >= you need to use to compare different intervals, so to say
whether either first's bottom is lower than second's top value or
whether first's top is lower than second's bottom value. But this kind
of interval compariso
think about it this way:
if the line is fully left, fully right, fully above or fully beneath
the rectangle, it's not close to the rectangle.
to find the closest approach to the rectangle you usually equate the
rectangle's border lines with the line to be compared as a function:
with exception o
Hey, supose i have a Rect and a Line, i just want to see if the line
intercepts the rect, is that possible somehow in a kind of optimized way ?
Im having trouble implementing this.
Thanks in advance !
On 2/20/2012 1:50 PM, Julian Marchant wrote:
> Hi, I tried searching the internet for an answer, but didn't find anything,
> so I'll ask here.
>
> One problem with normal collision detection I'm sure we're all aware of is
> the problem that objects moving too fast can pass through other objects
Ah, the linear equation. I'd forgotten about it, silly me. Thanks! I think I
can get that to work easily enough even without examples.
Regarding using multiple lines, that would be the ideal solution (it seems you
could do even better by having four lines for each object, one for each
corner),
Or if you like spoilers maybe somebuddy has some Python code you can rip,
like this guy:
http://code.google.com/p/gummworld2/source/browse/branches/tiled2/gamelib/gummworld2/geometry.py
Specifically, functions line_intersects_line and point_in_poly.
Gumm
On Mon, Feb 20, 2012 at 3:33 PM, Miriam
You could use the point of intersection between two lines.
One line is the bullet trajectory.
The other line is the target trajectory.
You have to take into account the time of the intersection too.
If the intersection falls inside the target at the right time for both
projectile and target then
On Mon, Feb 20, 2012 at 3:58 PM, Sam Bull wrote:
> Just a quick idea off the top of my head. What if you just get a rect
> covering from the bullets previous position to the bullets new position?
What about the diagonal motion?
I'd recommend something similar, though. Just test the line y=mx+b
Just a quick idea off the top of my head. What if you just get a rect
covering from the bullets previous position to the bullets new position?
Quick psuedo-code:
xpos = min(old.left, new.left)
xpos2 = max(old.right, new.right)
width = pos2 - pos
#Do the same for y/height
Rect(xpos, ypos, width, he
Hi, I tried searching the internet for an answer, but didn't find anything, so
I'll ask here.
One problem with normal collision detection I'm sure we're all aware of is the
problem that objects moving too fast can pass through other objects without a
collision happening. I'm experiencing this p
13 matches
Mail list logo