[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
2.2.9 Cutting sample
The last common thing which I want to show in this section is how one can cut off points from plot. There are 4 mechanism for that.
- You can set one of coordinate to NAN value. All points with NAN values will be omitted.
-
You can enable cutting at edges by
SetCut
function. As result all points out of bounding box will be omitted. -
You can set cutting box by
SetCutBox
function. All points inside this box will be omitted. -
You can define cutting formula by
SetCutOff
function. All points for which the value of formula is nonzero will be omitted. Note, that this is the slowest variant.
Below I place the code which demonstrate last 3 possibilities:
int sample(mglGraph *gr) { mglData a,c,v(1); mgls_prepare2d(&a); mgls_prepare3d(&c); v.a[0]=0.5; gr->SubPlot(2,2,0); gr->Title("Cut on (default)"); gr->Rotate(50,60); gr->Light(true); gr->Box(); gr->Surf(a,"","zrange -1 0.5"); gr->SubPlot(2,2,1); gr->Title("Cut off"); gr->Rotate(50,60); gr->Box(); gr->Surf(a,"","zrange -1 0.5; cut off"); gr->SubPlot(2,2,2); gr->Title("Cut in box"); gr->Rotate(50,60); gr->SetCutBox(mglPoint(0,-1,-1), mglPoint(1,0,1.1)); gr->Alpha(true); gr->Box(); gr->Surf3(c); gr->SetCutBox(mglPoint(0), mglPoint(0)); // switch it off gr->SubPlot(2,2,3); gr->Title("Cut by formula"); gr->Rotate(50,60); gr->CutOff("(z>(x+0.5*y-1)^2-1) & (z>(x-0.5*y-1)^2-1)"); gr->Box(); gr->Surf3(c); gr->CutOff(""); // switch it off return 0; }
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on March 21, 2014 using texi2html 5.0.