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: 718
Joined: Fri Aug 23, 2013 12:29 pm

Find closed figures within a group of points?

Post by DR White » Fri Apr 26, 2019 5:11 pm

I am working on a program for electrical technicians to learn about resistor circuits.
The user will place resistors between the black dots and the program will calculate
the circuit resistance. To start the program process, I need to first find each complete circuit
(closed figure). I also need to determine circuits (figures) that share the same side. I have attached
a pic and the beginning of the program. In the attached example, I need to determine that the Black, Green and Red squares are closed figures and that the Blue and Purple are open figures. Also, that the Black and Green figures share a side. I might eventually figure something out, but any guidance would be greatly appreciated.

Thanks,

David
Attachments
Circuit Resistace Finder_Info.livecode.zip
(3.38 KiB) Downloaded 244 times
Find_closed_Squares.png

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Find closed figures within a group of points?

Post by jmburnod » Fri Apr 26, 2019 5:44 pm

Hi David,
I played with your stack. Polygon grcs seems better than rectangle grcs in this case.
If i think correctly a polygon is closed if last point = first point.
Best regards
Jean-Marc
https://alternatic.ch

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Find closed figures within a group of points?

Post by dunbarx » Fri Apr 26, 2019 6:41 pm

Hi,

Jean-Marc led the way. The "points" of a graphic, though unfortunately they do not work with rectangle graphics, will let you do what you want. but you will be well served to set up a grid of some kind, a fairly coarse one at that, so that the points will snap together easily.

So if you look at the points of the black square and the green square, and again, these have to be polyLlines, not rectangles, each will have eight points. You can see how to proceed.

I bet there are many small issues to really make this easy to use. The ordering of points, or a common starting position, such as the topLeftMost, might be essential. A routine to find the common points between one or more graphics is probably essential.

When a resistor is placed at the intersection of two cirucuits you may have both parallel and series components in play. That is why the ordering of the pathway is critical

Sound like fun, though.

Craig

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Find closed figures within a group of points?

Post by DR White » Fri Apr 26, 2019 6:46 pm

Jean-Mark,

Thanks for downloading my LC file.
I was in a rush to show what I was trying to do and I did a VERY poor job.
I apologize!!!

Please download the file attached to this response, as it better represents what I am trying to do.

The user will put components between the black dots (either a resistor group or a line). I am looking for a way to identify the circuits (each closed rectangular with components). In the attached example, I need a way of finding and grouping the red items, finding and grouping green items and knowing that the purple items do not complete a closed circuit (rectangle).

Thanks So MUCH,

David
Attachments
Circuit Resistace Finder_Zip_2.livecode.zip
(4.97 KiB) Downloaded 205 times
Find_closed_Squares_2.png

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Find closed figures within a group of points?

Post by DR White » Fri Apr 26, 2019 8:52 pm

Craig,

I totally agree with you, that I will need components to "snap" into place. I also agree that there are many challenges to this app, but I know that LC can do it. its just a matter of finding out how.

Thanks for help,

David

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Find closed figures within a group of points?

Post by dunbarx » Fri Apr 26, 2019 10:15 pm

David.

Why is the unclosed section at the bottom not relevant? Might not the end of that section be a terminal of the resistor array? In other words, how do we know where the two ends are? There are many places they might be.

Craig

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Find closed figures within a group of points?

Post by jmburnod » Fri Apr 26, 2019 10:32 pm

Hi David,
I apologize!!!
Please, no apology (I've 'made worst) :D
I think you have to find a system allow to know intersections between objects. I mean a system based on object names.
You might rename you bullet like a grid (For example line of bullet "mybullet_Row_Range" like this:
"mybullet_1_1" "mybullet_1_2" etc...) for first line of bullet
"mybullet_1_2" "mybullet_1_3" etc...for second line of bullet

You will win a lot about your goal and the useful ways to find a solution.
Jean-Marc
https://alternatic.ch

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Find closed figures within a group of points?

Post by DR White » Fri Apr 26, 2019 10:56 pm

Craig,

The unclosed section at the bottom represents a circuit that the user did not complete and therefore its components are ignored.

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Find closed figures within a group of points?

Post by DR White » Fri Apr 26, 2019 10:59 pm

jmburnod,

I am thinking that your idea of ""mybullet_1_1" "mybullet_1_2" etc..." is a good idea and I will use it.

Thanks

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Find closed figures within a group of points?

Post by dunbarx » Sat Apr 27, 2019 1:19 am

David.

I am interested in how a circuit is constructed, then. Are you asking for calculations of mixtures of series and parallel resistance values, based on measurements taken at various points? In other words, I do not see anything special about either closed or open structures. But I will wait for you to get farther along...

Craig

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Find closed figures within a group of points?

Post by jmburnod » Sat Apr 27, 2019 9:36 am

Hi,
The "points" of a graphic, though unfortunately they do not work with rectangle graphics.
Yes, but we can use effective points for a grc rectangle.
I notice that if you set the points of a grc polygon to the effective points of a grc rectangle, you get a curious result as below.
iEffectivePointsrectangleVsPolygon.png
Fours points for both but it seems polygon is opened and the rectangle closed.
Jean-Marc
https://alternatic.ch

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Find closed figures within a group of points?

Post by DR White » Sat Apr 27, 2019 10:39 am

Craig,

Good questions!

The circuits are constructed loops within loops (rectangles) of components. I am not asking for calculations for finding the resistances, I am an Electrical engineer. I will be using what's called "Mesh Current" method. It is a somewhat complicated method using matrices, but it can solve most any resistor circuit (series, parallel or combination). But to use the "Mesh Current" method, I have to be able to identify each current loop (components (wires or resistors) that form a closed rectangle).

David
Last edited by DR White on Sat Apr 27, 2019 10:54 am, edited 2 times in total.

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Find closed figures within a group of points?

Post by DR White » Sat Apr 27, 2019 10:44 am

jmburnod,

The user will not actually be using grc rectangles. They will be constructing rectangular figures using wires and resistors. see pic from post by DR White » Fri Apr 26, 2019 12:46 pm.

Thanks,

David

bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Find closed figures within a group of points?

Post by bogs » Sat Apr 27, 2019 12:14 pm

DR White wrote:
Sat Apr 27, 2019 10:44 am
see pic from post by DR White » Fri Apr 26, 2019 12:46 pm.
Sorry David, trying to link a post that way will not work unless someone is in your own timezone.
Selection_001.png
The only place that shows...
The best way to link a post is to actually right click on the post title you want linked, copy the link, and then either post it raw or in linked text.
Selection_002.png
Would you like that raw, or linked?
Raw paste - https://forums.livecode.com/posting.php ... 9#pr179246
Linked -

Code: Select all

[url=https://forums.livecode.com/posting.php?mode=reply&f=7&t=32529#pr179246]Linked[/url]
The second best way is to just quote whichever post your talking about, and it will link the quoted post for you, in the blue arrow at the end of "wrote:"
DR White wrote:
Fri Apr 26, 2019 5:11 pm
I am working on a program for electrical technicians to learn about resistor circuits.
Hope that helps :)
Image

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Find closed figures within a group of points?

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

Thanks bogs

Post Reply