Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hello Everyone.
From :
How to fill the ( convex, concave, complex ) quadrilateral with color ?
Thanks in advance for your time and help.
Best Regards.
Loi.
Solved! Go to Solution.
Use old hatch function to fill the area.
Use 3D plot
Many thanks, Ttokoro. 🙄 🤔 I got your hint of convex quadrilateral.
But I have still stuck in the concave and complex quadrilateral.
Best Regards.
Change B and D.
Thanks again, Ttokoro. 😊 😊 🤔 Now, I think that we would need changing the intersection points "by hand" : ( Is there a way exchanging between intersection points with codes (program function) for three of case of convex, concave, and complex quadrilaterals. ? )
The last case : complex quadrilateral.
Regards.
After be named all points and lines, stacking Hatch function may be programable.
P is all points [x y] data. data is 3 points numbers to make triangle and stack all triangles.HatchAll fill the triangles.
and another similar query :
Fill 3 of the close-shape ?
Can you attache also a Mathcad Prime file worksheet? it is not pretty visible in the image you have posted
and :
Many thanks for your last post, Ttokoro. 😊 🤔
Best Regards.
Loi.
Very easy to do. Only slight changes are necessary
Generally the approach with the boolean function which Prof. Birkeland had chosen is quite flexible and powerful, yet easy to use.
For example
Would be significantly more work to achieve with other methods, I guess.
Here another, simpler example, which could easily also created using the "classic" Hatch/Fill function with its vertical lines
IMHO using Prof. Birkeland's functions is much easier and more fun 😉
If you don't want to dig into the details, the very first function Dots() is all you need for a simple fill. Only filling with hatch lines (of arbitrary angle) or with a family of arbitrary curves would need the other functions.
Setting up the boolean functions which define the area is more logical and easier as opposed to having to think about intersecting which curves and then assemble the areas to be colored from the correct partial areas via stack().
Intersecting the curves was only done for the orange filled area because of the way I decided it has to look like (and I just notice that in the definition of orange(x,y) we could omit the y<blue(x) part).
As seen with the turquoise colored area one benefit of using dots is that we can let the axis ticks and numbers see through as otherwise (seen at the yellow and magenta colored area) the axis are overlaid (this is different from the behaviour in Prime).
You may also chose to change the trace type from "point" to "line" to get kind of a zig-zag fill. I tried but I didn't like it.
Thanks again, Werner. 😊 🤔. I got it :
Best Regards.
Maybe the work of Prof. Birkeland can help, too.
See attachment in this posting: https://community.ptc.com/t5/Mathcad/How-to-fill-the-area-under-the-curve-with-colours/m-p/888943/highlight/true#M207711
As you are using real Mathcad you probably are rather interested in the predecessor for Mathcad 15. Its attached here.
BTW, four lines do NOT define a unique quadrilateral as you can see here:
Better you provide the vertices and keep in mind, that the order in which you provide the points matter!
To use Prof. Birkeland's functions you will have to provide a boolean function which determines if a point is inside the to-be-hatched area or not.
I vaguely remember that I provided that kind of "pointInPolygon" function in an older thread for a different purpose, but it seems that I did not keep a copy and I could not find that thread with a quick search.
Birkeland provides three functions to fill shapes in his worksheet, Dots, Hatch and Shade.
Dots is the most simple one and can be used to fill arbitrary polygons with an orthogonal dot grid. Varying the number of dots and their size you may also simulate a plain fill.
After quite some reformatting it worked in Prime, too, but unfortunately Prime is limited concerning the number of different line widths (=point sizes in Prime) and the number of points its can plot while respecting the set line width, The center plot with about 17000 points won't work OK because of this limitation and the number of dots had to be reduced.