Find closed figures within a group of points?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

DR White
Posts: 686
Joined: Fri Aug 23, 2013 12:29 pm
Location: Virginia, USA

Re: Find closed figures within a group of points?

Post by DR White » Sat Apr 27, 2019 1:31 pm

For anyone who is interested in following my quest for "finding closed figures within a group of points".
Attached my latest progress using the input from forum.

I added small boxes to each point to later use a routine to detect the intersection of a wire or resistor with the point. I still have not found a simple way to find the resistor loops (rectangles containing resistors and wires).

Thanks,

David
Attachments
Circuit Resistace Finder_Zip_3.livecode.zip
(9.9 KiB) Downloaded 160 times
Find_closed_Squares_3.png

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Find closed figures within a group of points?

Post by jmburnod » Sat Apr 27, 2019 1:54 pm

Hi David,
if you give a relevant name for yours groups (you began it with "Resistor_A"), this will be clearer and you will be able to define yours loops.
Best
Jean-Marc
https://alternatic.ch

DR White
Posts: 686
Joined: Fri Aug 23, 2013 12:29 pm
Location: Virginia, USA

Re: Find closed figures within a group of points?

Post by DR White » Sat Apr 27, 2019 2:39 pm

Jean-Marc,

I have update my LC file with relative name on the resistors to define the loops. In this example, I have three loops:
Loop 1 - Resistor_1, Resistor_2, Resistor_3, Resistor_6, Resistor_9, Resistor_11, Resistor_12
Loop 2 - Resistor_4, Resistor_5, Resistor_6, Resistor_7, Resistor_8
Loop 3 - Resistor_8, Resistor_9, Resistor_10

Is there a relative easy way of for a routine to find these three loops?

Thanks,

David
Attachments
Circuit Resistace Finder.livecode 4.zip
(10.05 KiB) Downloaded 163 times

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Find closed figures within a group of points?

Post by jmburnod » Sat Apr 27, 2019 4:14 pm

David
Relevant naming becomes the base for me.
I lost a lot of times avoiding this step.
Probably use array would be a good way in this case
I'm not a specialist but I'am sure someone will help soon
Best
Jean-Marc
https://alternatic.ch

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9656
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Find closed figures within a group of points?

Post by dunbarx » Sat Apr 27, 2019 5:36 pm

I still have not found a simple way to find the resistor loops
I still do not know the basic intent. It has always been to create closed loops, not to create resistor networks, which do not require closure. I do understand that you need at least one closed loop since I now see a voltage source in the mix.

If you set a string point, and I highly recommend that you do, say, always the upper left at the anode, and you have mapped and named the grid intersections. you can use brute force to find you way through what essentially a maze.

So if you travel you will know the names of the adjacent points. You can then see if there are any components there. These might orient in one of three possible directions. A property of each MUST have its orientation as well as its points. Try one after another, always in the same order, collecting components and their map locations until you find yourself at the cathode.

This is real brute force, as I said. In your latest picture, you start upwards. You continue up until you either find yourself at the border or find a component. You do indeed find a component, and it is a wire going to the right.
Just keep going. You will get to points with two or more filled adjacent points. Collect them all. Keep track. When you get to the cathode, you have a list of connections.

I still think that unclosed pathways have merit.

Fun

Craig

DR White
Posts: 686
Joined: Fri Aug 23, 2013 12:29 pm
Location: Virginia, USA

Re: Find closed figures within a group of points?

Post by DR White » Sat Apr 27, 2019 6:06 pm

Craig,

The intent of this app is to provide a tool for finding the total resistance of groups of resistors that the user configures between the dots. To calculate the total resistance using the "Mesh Current" method, I need to have current flow through each circuit. That is why there is a voltage source and why the loops have to be closed.

You are right, there must be a starting point and that point is the anode of the voltage source. The end point of one of the loops will need to be at the cathode.

So the point of this app is to allow the user to quickly create a resistor group for which he or she is wanting to know the total resistance of.

I am thinking that your "brute force" method may be the only way to accomplish my goal of finding all the loops within the group of points.

Thanks,

David

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9656
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Find closed figures within a group of points?

Post by dunbarx » Sat Apr 27, 2019 10:37 pm

David.

Just reread the entire thread, and missed a couple of replies, which is why I kept harping on what your intent was and why you needed closed loops. :oops:

There are probably methods in several disciplines that can do this much more cleverly. If Euler could do it with the Konigsberg bridges, LC can do it with brute force. It will be fun if you don't get bogged down with the forks on top of the forks.

Craig

DR White
Posts: 686
Joined: Fri Aug 23, 2013 12:29 pm
Location: Virginia, USA

Re: Find closed figures within a group of points?

Post by DR White » Sun Apr 28, 2019 11:47 am

Thanks Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”