## Overllaping matrices

General discussion about LÖVE, Lua, game development, puns, and unicorns.
tetsuken
Prole
Posts: 13
Joined: Sat May 25, 2013 10:42 pm

### Overllaping matrices

HI again, i start to studie random dungeon generation and i try find matrix intersections for love2d and for lua and i didnt found. Usually in c++ and c# there is a simple command for that. There any one who knows how i can do this in love2d?

Ty for any help

Yell0w
Prole
Posts: 28
Joined: Wed Nov 21, 2012 7:40 am
Location: Norway
Contact:

### Re: Overllaping matrices

You can maybe write a small function similar to this (i dont know of an existing command to do it automatically)

pseudo function isIntersection(x,y) begin
var totalconnections = 0
if exists(x+1,y) then totalconnections = totalconnections+1)
next plx

end
You can learn anything, but you cannot learn everything!

raidho36
Party member
Posts: 1994
Joined: Mon Jun 17, 2013 12:00 pm

### Re: Overllaping matrices

What kind of simple command? A C++ library function? You can search appropriate Lua library then.

vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

### Re: Overllaping matrices

Can you specify what you mean by 'matrix intersection'? I've never heard this term before.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine

raidho36
Party member
Posts: 1994
Joined: Mon Jun 17, 2013 12:00 pm

### Re: Overllaping matrices

I suppose he means a function to find sub-matrix in the matrix.

szensk
Party member
Posts: 155
Joined: Sat Jan 19, 2013 3:57 am

### Re: Overllaping matrices

from my naive mind, do a rectangle intersection for each axis. obviously it's a bad idea as you only need 8 points...
Last edited by szensk on Fri Aug 23, 2013 5:06 am, edited 3 times in total.

Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

### Re: Overllaping matrices

I'm working on that OP, I'll currently recreating AdobeScripts geometry lib in löve so just wait a day or two and you'll see it in the Projects and Demos subforum (I can PM you if you want)

First release will have rectangleIntersection and rectangleUnion. Intersection'll return the ovelaping rectangle of both rectangles, if they aren't intersecting it'll return a rectangle with all vars being 0.

You can read more here and here

BTW, rectangle intersection is not an easy thing to do, that's why there's always a code on most programing languages to do that for you but there isn't one in löve.

Just gimme a day (or two, no more than four )
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping

Ref
Party member
Posts: 687
Joined: Wed May 02, 2012 11:05 pm

### Re: Overllaping matrices

[quote="Ranguna259"]
BTW, rectangle intersection is not an easy thing to do, that's why there's always a code on most programing languages to do that for you but there isn't one in löve.
quote]
Is this where you are heading?
Attachments
overlap.love
Determine overlap area of two polygons

tetsuken
Prole
Posts: 13
Joined: Sat May 25, 2013 10:42 pm

### Re: Overllaping matrices

Ty all for the posts.
By matrix intersections i mean, 2 matrices in one bigger matrix that are overllaping each other(someone asked) and i need this because im planning use a matrix to handle my tileset of images and collisions, this way i can check if one room(matrix) is not overllaping other room before carve it on the tile.
Sorry if im not been clear, english is not my native language.

Any way if some one could send a sample i will aprecciate.

This is what my mind can think by now:

function findIntersect(M1,M2)

i,j = 1,1
intersect = {}

while i < M1 and j < M2 do

if M1 == M2 then
i,j = i+1,j+1
table.insert(intersect,M1)
else if M1 > M2[j] then
M1,M2 = M2,M1
i,j = j,i
else
i = i + 1
end
return intersect
end

this is pieces of what i found on net, if its wrong of anyone have better ideas i will aprecciate.

ty again and ty for future helps.

vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

### Re: Overllaping matrices

I still don't quite understand what you want to do: What is does it mean if two matrices overlap?
I think of matrices as tables of numbers, for example:
$A = \left(\begin{array}{cccc} 1 & 2 & 3 & 4\\ 5 & 6 & 7 & 8\\ 9 & 8 & 7 & 6\\ 5 & 4 & 3 & 2\end{array}\right) \text{ and } B = \left(\begin{array}{cccc} 6 & 7 & 0 & 0\\ 8 & 7 & 0 & 0\\ 0 & 0 & 1 & 2\\ 0 & 0 & 5 & 6\end{array}\right)$
Would those two matrices 'overlap' with $\left(\begin{array}{cc}1 & 2\\ 5&6\end{array}\right)$? What is the output you'd expect from findIntersect(A,B)? Can you name a function in a different language that does what you want?

 tags when posting code.
Side note 2: Guys, I don't think he's asking about rectangle intersection. Also, there is a [wiki=BoundingBox.lua]wiki entry[/wiki] for that.