Calculate area between objects

Calculate area between objects

Anonymous
Not applicable
4,052 Views
5 Replies
Message 1 of 6

Calculate area between objects

Anonymous
Not applicable

What is the best way to calculate area between two polylines and two xlines?

 

see attaxhed file.

 

0 Likes
4,053 Views
5 Replies
Replies (5)
Message 2 of 6

Norman_Yuan
Mentor
Mentor

It would depend on the scenrio when/how the process goes to the point when the area is needed.

 

If in the process where user can see the area and have chance to visually identify the area (such as pick inside the enclosed area), then yo can call Editor.TraceBoundary(), which returns a DBCollection with only one Curve in it. So, you get Curve.Area.

 

If your code can automatically locate a point inside the enclosed area, then, of course, Editor.TraceBoundary() is the easiest way.

 

Or, if your code can somehow identify all the curves that form the area (2 polylines and 2 XLines here), you can use IntersectWith() to find all the intersection points and then somwhow in conjunction with the polylines' vertices to form a boundary polyline, then you know the area.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 6

Anonymous
Not applicable

Thanks for response. My code knows all 4 curves so i have to use last option. when I find intersections of xline with lines , how I get boundery polyline ?


@Norman_Yuan wrote:

It would depend on the scenrio when/how the process goes to the point when the area is needed.

 

If in the process where user can see the area and have chance to visually identify the area (such as pick inside the enclosed area), then yo can call Editor.TraceBoundary(), which returns a DBCollection with only one Curve in it. So, you get Curve.Area.

 

If your code can automatically locate a point inside the enclosed area, then, of course, Editor.TraceBoundary() is the easiest way.

 

Or, if your code can somehow identify all the curves that form the area (2 polylines and 2 XLines here), you can use IntersectWith() to find all the intersection points and then somwhow in conjunction with the polylines' vertices to form a boundary polyline, then you know the area.


 

0 Likes
Message 4 of 6

SENL1362
Advisor
Advisor

The picture shows linear polylines (all Bulges are 0)
If this is always true then you could solve the problem with:
1. calculare the four intersection points;
2. calc area beneath upper polyline from x=xline_left.. xLine_right
3. calc area beneath lowe polyline from x=xline_right..xline_left
4. sum both values.

choise an y is ybase(or bottom) =MIN(yVertices)

You have to calculate circle cone area's when the polyline segments are not linear.

A bit more complicated.

 

 

0 Likes
Message 5 of 6

Anonymous
Not applicable

Yes but  how I calculate area beneath polyline(integral)? 

0 Likes
Message 6 of 6

SENL1362
Advisor
Advisor

As i said it depends. If linear segments, you can think of a trapezoid and it's area is:

dx = x2 - x1: dy = y2 - y1

areaTriangle = 0.5 * dx * dy
areaRectangle = dx * y1
areaTrapezoid = areaTriangle + areaRectangle

Continue for the rest of the vertices and sum all Trapezoid area's.

 

When not linear segments (bulge <> 0) the area equals: areaCircleSector+2*areaTrapezoid. 

(Arc Segment is  rotatedCircleSector+Trapezoid(p2,pc)+Trapezoid(pc,p1)

areaCircleSector = r * r * 0.5 * sweepAngle   ' Calculate the Sector, not the Segment  "*(sweep - Sin(sweep))"

Add areaTrapezoid(pc, p1)+areaTrapeziod(p2, pc)

the radius can have a positive and negative value, dependig of a hole segment or a icecream like shape.

 

I used to use the circle sector and not a circle segment because it enabled me to calculate the centroid and inertia of segments as well.

It's relatively easy for a rotated circle sector but not for a rotated circle segment.

 

 

 

0 Likes