Author Topic: Geometry problem: length of segments knowing the area, perimeter and width  (Read 8424 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
I have a polyline that I know:
area         = 1512499.7 ...
perimeter = 12600
width of the track = 250 (in the example)

Is it possible calculate the total length of the segments?
(as in the picture: 3000+1000+950+1100 = 6050)


irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
It's possible to calculate mathematically, but for one thing: Your dimensions are inconsistent as to what they measure. E.g. that "700" long piece is actually ... what ... 700+250?
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Total length = Total area / width = 1512499.7 / 250.0 = 6049.9988 ~ 6050 = 3000 + 1000 + (700+250) + 1100
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

tombu

  • Bull Frog
  • Posts: 289
  • ByLayer=>Not0
You are looking to select segments of a polyline and total the lengths of those segments?
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
It's possible to calculate mathematically, but for one thing: Your dimensions are inconsistent as to what they measure. E.g. that "700" long piece is actually ... what ... 700+250?
I'm sorry, you're absolutely right (i have altered the image) here are other examples:

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Total length = Total area / width = 1512499.7 / 250.0 = 6049.9988 ~ 6050 = 3000 + 1000 + (700+250) + 1100
Yes, I did not think it was that simple, I hope that there are no exceptions...
Grazie mille.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #6 on: November 21, 2014, 08:54:37 AM »
New question: is  there a way to calculate the maximum lenght of the profile as in the examples A and B?

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #7 on: November 21, 2014, 09:15:07 AM »
Why isn't the max. length of A: 3000+1000+250+1200+1100=6550?

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #8 on: November 21, 2014, 09:23:51 AM »
Why isn't the max. length of A: 3000+1000+250+1200+1100=6550?

Roy, probably thought :
Why isn't the max. length of A: 3000+750+250+1200+1100=6300?
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Bethrine

  • Guest
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #9 on: November 21, 2014, 09:29:29 AM »
A: 3000+1000+(1200-250)+1100=6050


ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #10 on: November 21, 2014, 09:40:05 AM »
Why isn't the max. length of A: 3000+1000+250+1200+1100=6550?

Roy, probably thought :
Why isn't the max. length of A: 3000+750+250+1200+1100=6300?

I think the answer is : How can center polylines length be the same as those that are offset by half the width (250/2=125) ? Simply it can't be the same length - those polylines aren't colinear - they are curving in all 4 orthogonal ways (+X,-X,+Y,-Y)...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Bethrine

  • Guest
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #11 on: November 21, 2014, 10:03:25 AM »
 :?

I am not a programmer. I found it interesting as a math problem. Feel free to ignore me!  :-)

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #12 on: November 21, 2014, 10:40:29 AM »
I asked the question too early and without considering well: is a matter for the calculation of square tubing to build the figure, is a question that I was asked but I think that the calculation of the other figures is not correct. I think the request is just to know the total length of pipe required.

So in the example top/left the length is: 1160+1050+750 = 3000

@roy_043 > Why isn't the max. length of A: 3000+1000+250+1200+1100=6550?
        maybe this is the exact calculation  A: 3000+1000+500+1200+1100=6800

Now ask other explanations.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #13 on: November 21, 2014, 10:49:37 AM »
Do you intend on making miter joints or butt joints?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

owenwengerd

  • Bull Frog
  • Posts: 451
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #14 on: November 21, 2014, 12:08:12 PM »
I think the request is just to know the total length of pipe required.

In that case the solution is very simple: calculate total enclosed area of the figure divided by width of the tubing.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #15 on: November 21, 2014, 12:33:04 PM »
Do you intend on making miter joints or butt joints?
I'm sorry but I did not understand the translation.

@owenwengerd:Thanks for answer.

 This should be the solution:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #16 on: November 21, 2014, 01:20:59 PM »
See example
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.


Bethrine

  • Guest
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #18 on: November 21, 2014, 03:54:56 PM »
6550

You need the longer side.


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #20 on: November 21, 2014, 04:29:27 PM »
Well there is a better way. Need to add the blade widths
Green & magenta are flipped for cutting.
6550-6300=250 x250=62,500 in savings

You would need center line length from butt to butt.
« Last Edit: November 21, 2014, 04:42:13 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #21 on: November 21, 2014, 04:49:21 PM »
OK, this is valid. Now try with a sqared tube open on the top and closed with a cover so the magenta part can not be mirrored. Sorry for my english and the confusion.


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #22 on: November 21, 2014, 05:06:40 PM »
Not sure I understand.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #23 on: November 22, 2014, 04:15:09 AM »
Sorry for my english:

1) a project may have from 20 to 200 of these conduits
2) the drawing of the conduits is 2D and with Polylines (closed or not > flag 70 = 0 or 1)
3) each conduits is made to measure and numbered
4) all joints are miter

Problem: find the total length of the conduits by considering each piece without any cut at 45 degrees.

I understand that with a program similar to the nesting is possible to calculate the optimized cutting considering all the conduits but, for simplicity, we consider as if the conduits are cut all at 90 degrees (before) and then 45 degrees where it serves to

I hope that my/google translation is understandable.

owenwengerd

  • Bull Frog
  • Posts: 451
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #24 on: November 22, 2014, 09:41:47 AM »
In that case the formula is (+ (/ enclosed-area conduit-width) (* conduit-width number-of-miters)).

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #25 on: November 22, 2014, 09:58:55 AM »
In that case the formula is (+ (/ enclosed-area conduit-width) (* conduit-width number-of-miters)).
I had thought of such a thing, but how do I calculate the "number-of-miters"?

>>> 4) all joints are miter

In doubt, maybe I should specify: 4) all "L" joints are miter (not "T" joints)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #26 on: November 22, 2014, 10:25:22 AM »
Wow, 25 post & we finally get to see the entire problem.

The conduit is a "Raceway" made of channel shape material
No interior obstructions allowed.
Connections will be miter joints.
Material is open one side & therefore can not be flipped upside down
Butt joints could be made on tee connections with a window cut in the "run" member.

Does that sum it up?  :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #27 on: November 22, 2014, 11:59:55 AM »
Wow, 25 post & we finally get to see the entire problem.

The conduit is a "Raceway" made of channel shape material
No interior obstructions allowed.
Connections will be miter joints.
Material is open one side & therefore can not be flipped upside down
Butt joints could be made on tee connections with a window cut in the "run" member.

Does that sum it up?  :)
In addition to the language problem is also that I do not deal with these constructions.
I humbly apologize...  :'( :oops:      :| now believe that nothing is missing. Thank you for your patience.

owenwengerd

  • Bull Frog
  • Posts: 451
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #28 on: November 22, 2014, 01:12:55 PM »
I had thought of such a thing, but how do I calculate the "number-of-miters"?

Each joint consists of two vertices. If the vertices are connected orthogonally, it is a butt joint; otherwise a miter joint. So the problem is reduced to grouping the vertices into orthogonal and non-orthogonal groups, then dividing the number of non-orthogonal vertices by two. I don't think this is a very difficult problem given that orthogonal vertices are always the conduit width apart.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #29 on: November 22, 2014, 02:57:03 PM »
I had thought of such a thing, but how do I calculate the "number-of-miters"?

Each joint consists of two vertices. If the vertices are connected orthogonally, it is a butt joint; otherwise a miter joint. So the problem is reduced to grouping the vertices into orthogonal and non-orthogonal groups, then dividing the number of non-orthogonal vertices by two. I don't think this is a very difficult problem given that orthogonal vertices are always the conduit width apart.
Thanks Owen, I think this is a good start. Good weekend!
 

GP

  • Newt
  • Posts: 83
  • Vercelli, Italy
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #30 on: November 22, 2014, 07:13:34 PM »
My attempt  :-)


owenwengerd

  • Bull Frog
  • Posts: 451
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #31 on: November 22, 2014, 07:41:19 PM »
I think it would be best to withhold your solutions until Marco has tried on his own, else you deny him the opportunity to learn from the experience.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #32 on: November 23, 2014, 02:40:20 PM »
I think it would be best to withhold your solutions until Marco has tried on his own, else you deny him the opportunity to learn from the experience.
you're right, I was trying but I would never have done such a thing!

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #33 on: November 23, 2014, 02:47:50 PM »
My attempt  :)
this is not an attempt but it is much more  :o      tomorrow I'll try as soon as possible...
 

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #34 on: November 23, 2014, 04:12:46 PM »
My attempt is like Owen described in a few steps... No need for using additional routine...
Minimally tested...

Code: [Select]
(defun c:STL-all ( / vk_IsPointInside chk2ptcitouch ss le tl i lw ar ll ptlst ptlstn d1 d2 d3 d4 mitter )

  (defun vk_IsPointInside ( Point PointsList / PY P1Y P2Y )
  ; works with polygons only, i.e. if (equal (car PointsList) (last PointsList))
    (if (cdr PointsList)
      (/= (and (or (and (<= (setq PY  (cadr Point)
                                  P2Y (cadadr PointsList)
                                  P1Y (cadar PointsList)
                            )
                            PY
                        )
                        (< PY P2Y)
                    )
                    (and (> P1Y PY) (>= PY P2Y))
                )
                (> (car Point)
                    (+ (* (/ (- PY P1Y) (- P2Y P1Y))
                          (- (caadr PointsList) (caar PointsList))
                       )
                       (caar PointsList)
                    )
                )
          )
          (vk_IsPointInside Point (cdr PointsList))
      )
    )
  )

  (defun chk2ptcitouch ( p r lw / p1 p2 p3 p4 chk ) (vl-load-com)
    (setq p1 (mapcar '+ (list (car p) (cadr p) 0.0) (list r 0.0 0.0)))
    (setq p2 (mapcar '+ (list (car p) (cadr p) 0.0) (list (- r) 0.0 0.0)))
    (setq p3 (mapcar '+ (list (car p) (cadr p) 0.0) (list 0.0 r 0.0)))
    (setq p4 (mapcar '+ (list (car p) (cadr p) 0.0) (list 0.0 (- r) 0.0)))
    (setq chk 0)
    (if (vlax-curve-getparamatpoint lw p1) (setq chk (1+ chk)))
    (if (vlax-curve-getparamatpoint lw p2) (setq chk (1+ chk)))
    (if (vlax-curve-getparamatpoint lw p3) (setq chk (1+ chk)))
    (if (vlax-curve-getparamatpoint lw p4) (setq chk (1+ chk)))
    (if (eq chk 2) T nil)
  )
 
  (prompt "\nSelect all square-tube LWPOLYLINES")
  (setq ss (ssget (list '(0 . "LWPOLYLINE") '(-4 . "<or") '(70 . 1) '(70 . 129) '(-4 . "or>")
                  )
           )
  )
  (while (null ss)
    (prompt
      "\nEmpty sel.set... Please try selecting all square-tube LWPOLYLINES again..."
    )
    (setq ss (ssget (list '(0 . "LWPOLYLINE") '(-4 . "<or") '(70 . 1) '(70 . 129) '(-4 . "or>")
                    )
             )
    )
  )
  (initget 7)
  (setq le (getdist "\nPick or specify conduit width : "))
  (setq tl 0.0)
  (setq d1 (list le le))
  (setq d2 (list (- le) le))
  (setq d3 (list le (- le)))
  (setq d4 (list (- le) (- le)))
  (repeat (setq i (sslength ss))
    (setq lw (ssname ss (setq i (1- i))))
    (command "_.AREA" "_O" lw)
    (setq ar (getvar 'area))
    (setq ll (/ ar le))
    (setq ptlst (mapcar 'cdr
                        (vl-remove-if-not
                          '(lambda ( x ) (eq (car x) 10))
                          (entget lw)
                        )
                )
    )
    (setq ptlstn (reverse (cons (car ptlst) (reverse ptlst))))
    (setq mitter 0)
    (foreach pt ptlst
      (if
        (cond
          ( (and
              (vl-some '(lambda ( x ) (equal (mapcar '+ pt d1) x 1e-5)) ptlst)
              (vk_IsPointInside (mapcar '+ pt (mapcar '/ d1 (list 2.0 2.0))) ptlstn)
              (chk2ptcitouch (mapcar '+ pt (mapcar '/ d1 (list 2.0 2.0))) (/ le 2) lw)
            )
            T
          )
          ( (and
              (vl-some '(lambda ( x ) (equal (mapcar '+ pt d2) x 1e-5)) ptlst)
              (vk_IsPointInside (mapcar '+ pt (mapcar '/ d2 (list 2.0 2.0))) ptlstn)
              (chk2ptcitouch (mapcar '+ pt (mapcar '/ d2 (list 2.0 2.0))) (/ le 2) lw)
            )
            T
          )
          ( (and
              (vl-some '(lambda ( x ) (equal (mapcar '+ pt d3) x 1e-5)) ptlst)
              (vk_IsPointInside (mapcar '+ pt (mapcar '/ d3 (list 2.0 2.0))) ptlstn)
              (chk2ptcitouch (mapcar '+ pt (mapcar '/ d3 (list 2.0 2.0))) (/ le 2) lw)
            )
            T
          )
          ( (and
              (vl-some '(lambda ( x ) (equal (mapcar '+ pt d4) x 1e-5)) ptlst)
              (vk_IsPointInside (mapcar '+ pt (mapcar '/ d4 (list 2.0 2.0))) ptlstn)
              (chk2ptcitouch (mapcar '+ pt (mapcar '/ d4 (list 2.0 2.0))) (/ le 2) lw)
            )
            T
          )
          ( T nil )
        )
        (setq mitter (1+ mitter))
      )
    )
    (setq tl (+ tl (+ ll (* le (/ mitter 2)))))
  )
  (prompt
    "\nTotal length of all square-tube LWPOLYLINES is : "
  )
  (princ (rtos tl 2 50))
  (princ)
)

Your turn for testing...
Kr. M.R.
« Last Edit: November 26, 2014, 01:42:17 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #35 on: November 24, 2014, 12:17:43 PM »
My attempt  :)
Very well, the program is slow because it performs a very complex calculation, I have to review something for use with polylines with "straight" vertices and with width of the conduit is not perfect (249.9999).
Grazie ancora!
My attempt is like Owen described in a few steps... No need for using additional routine...
Minimally tested...
...
Your turn for testing...
Kr. M.R.
This is very fast, I have to review something for use with polylines with "straight" vertices and for lenth of the conduit equal to width (see my dwg).
Grazie mille for your time.

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #36 on: November 26, 2014, 01:44:25 PM »
Hi Marc'... I've changed my code to include cases when segment lengths are the same as conduit width... Try my code updated above and test it to see if everything's OK...

Kr. M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #37 on: November 26, 2014, 03:12:46 PM »
Hi Marc'... I've changed my code to include cases when segment lengths are the same as conduit width... Try my code updated above and test it to see if everything's OK...

Kr. M.R.
Grazie ancora, I need few days to test, now I have new problems to solve...
Ciao.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Geometry problem: length of segments knowing the area, perimeter and width
« Reply #38 on: December 09, 2014, 11:04:16 AM »
Hi Marc'... I've changed my code to include cases when segment lengths are the same as conduit width... Try my code updated above and test it to see if everything's OK...

Kr. M.R.
Hi Marko, with a "little" delay I finally managed to try fully your solution and it works perfectly. I just have to add the option to have width of the conduit is not accurate (249.9999).
Thanks again.     Marco