Overllaping matrices
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
Ty for any help
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
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!
Re: Overllaping matrices
What kind of simple command? A C++ library function? You can search appropriate Lua library then.
Re: Overllaping matrices
Can you specify what you mean by 'matrix intersection'? I've never heard this term before.
Re: Overllaping matrices
I suppose he means a function to find submatrix in the matrix.
 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.
You can read more about the lib's content here
Just gimme a day (or two, no more than four )
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.
You can read more about the lib's content here
Just gimme a day (or two, no more than four )
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?
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
 (3.2 KiB) Downloaded 82 times
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.
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.
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?
Side note 1: please use
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?
Side note 1: please use
Code: Select all
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.
Who is online
Users browsing this forum: No registered users and 7 guests