Page 1 of 2

Find closed figures within a group of points?

Posted: Fri Apr 26, 2019 5:11 pm
by DR White
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

Re: Find closed figures within a group of points?

Posted: Fri Apr 26, 2019 5:44 pm
by jmburnod
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

Re: Find closed figures within a group of points?

Posted: Fri Apr 26, 2019 6:41 pm
by dunbarx
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

Re: Find closed figures within a group of points?

Posted: Fri Apr 26, 2019 6:46 pm
by DR White
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

Re: Find closed figures within a group of points?

Posted: Fri Apr 26, 2019 8:52 pm
by DR White
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

Re: Find closed figures within a group of points?

Posted: Fri Apr 26, 2019 10:15 pm
by dunbarx
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

Re: Find closed figures within a group of points?

Posted: Fri Apr 26, 2019 10:32 pm
by jmburnod
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

Re: Find closed figures within a group of points?

Posted: Fri Apr 26, 2019 10:56 pm
by DR White
Craig,

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

Re: Find closed figures within a group of points?

Posted: Fri Apr 26, 2019 10:59 pm
by DR White
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

Re: Find closed figures within a group of points?

Posted: Sat Apr 27, 2019 1:19 am
by dunbarx
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

Re: Find closed figures within a group of points?

Posted: Sat Apr 27, 2019 9:36 am
by jmburnod
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

Re: Find closed figures within a group of points?

Posted: Sat Apr 27, 2019 10:39 am
by DR White
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

Re: Find closed figures within a group of points?

Posted: Sat Apr 27, 2019 10:44 am
by DR White
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

Re: Find closed figures within a group of points?

Posted: Sat Apr 27, 2019 12:14 pm
by bogs
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 :)

Re: Find closed figures within a group of points?

Posted: Sat Apr 27, 2019 1:18 pm
by DR White
Thanks bogs