70001120 How can i get all the points of the bounding box

Article 70001120
Type HowTo
Product WebJS
Version 7
Date Added 7/7/2017
Fixed 7.7012.0.3 (7/7/2017)
Submitted by Daniel Borquaye

Summary

How can i get all the points of the bounding box in WebControl

Solution

We want for example to get all the point of the bounding box of a line.
So at first we create a new line:var line = vdcanvas.AddLine([0, 0, 0],[2, 2, 2],true);
After this we create the bounding box of the entity which is the line: var bbox = vdcanvas.GetEntityBBox(line); 
The bounding box contains an array of six doubles which are two points,the bottom lower left point and the top upper right point. 
The first point that we will get is the bottom lower left point of the bounding box which has [Xmin,Ymin,Zmin]: var pt1 = vdgeo.newpoint(bbox[0], bbox[1], bbox[2]);
The second point that we will get is the top upper right point of the bounding box which has [Xmax,Ymax,Zmax]: var pt5 = vdgeo.newpoint(bbox[3], bbox[4],  bbox[5]);

After we have already found the bottom lower left point and the top upper right point of the bounding box we are able to find all of the other points.
The bottom lower right point of the bounding box  which has [Xmax,Ymin,Zmin] will be: pt2 = vdgeo.newpoint(bbox[3], bbox[1],  bbox[2]);
The bottom upper left point of the bounding box which has [Xmin,Ymax,Zmin] will be: pt3 = vdgeo.newpoint(bbox[0], bbox[4],  bbox[2]);
The bottom upper right point of the bounding box which has [Xmax,Ymax,Zmin]: var pt4 = vdgeo.newpoint(bbox[3], bbox[4],  bbox[2]);

We have found now all of the four points of the bottom bounding box and the only thing he have to do is to find also the top four points of the bounding box.
These four top points will be the same as the bottom with the difference that Zmin will be now Zmax.

The top lower left point of the bounding box which has [Xmin,Ymin,Zmax] will be: var pt6 = vdgeo.newpoint(bbox[0], bbox[1], bbox[5]);
The top lower right point of the bounding box which has [Xmax,Ymin,Zmax] will be: pt7 = vdgeo.newpoint(bbox[3], bbox[1],  bbox[5]);
The top upper left point of the bounding box which has [Xmin,Ymax,Zmax] will be: pt8 = vdgeo.newpoint(bbox[0], bbox[4],  bbox[5]); 

Send comments on this topic.