public BoundsD GetBoundsD() { BoundsD res = new BoundsD(vert.positionD, Vector3D.zero); res.Encapsulate(prev.vert.positionD); return(res); }
static List <Vertex> CreateBoundingTriangle(HMesh mesh, List <Vector3D> position) { BoundsD b = new BoundsD(position[0], Vector3D.zero); for (int i = 1; i < position.Count; i++) { b.Encapsulate(position[i]); } // encapsulate triangle b.center = b.center + b.extents * 3.1f; b.extents = b.extents * 10000f; Vector3D v1 = b.min; Vector3D v2 = b.min + Vector3D.forward * b.size.z; Vector3D v3 = b.min + Vector3D.right * b.size.x; Face face = mesh.CreateTriangle(v1, v2, v3); List <Vertex> boundingVertices = new List <Vertex>(); foreach (var he in face.Circulate()) { boundingVertices.Add(he.vert); } return(boundingVertices); }
public static BoundsD NormalizeIcon(Icon icn, int size) { double max = icn.bounds.w > icn.bounds.h ? icn.bounds.w : icn.bounds.h; float factor = size / (float)max; BoundsD bounds = new BoundsD() { l = double.MaxValue, t = double.MaxValue }; foreach (var path in icn.arr_svgpath) { SvgParser parser = SvgParser.FromPath(path); parser._scaler.OffsetXY((float)-icn.bounds.l, (float)-icn.bounds.t); parser._scaler.Scale(factor); if (parser._bounds.w > bounds.w) { bounds.w = parser._bounds.w; } if (parser._bounds.h > bounds.h) { bounds.h = parser._bounds.h; } if (parser._bounds.l < bounds.l) { bounds.l = parser._bounds.l; } if (parser._bounds.t < bounds.t) { bounds.t = parser._bounds.t; } } return(bounds); }
/// <summary> /// <para>Does another bounding box intersect with this bounding box?</para> /// </summary> /// <param name="bounds"></param> public bool Intersects(BoundsD bounds) { if ((double)this.min.x <= (double)bounds.max.x && (double)this.max.x >= (double)bounds.min.x && ((double)this.min.y <= (double)bounds.max.y && (double)this.max.y >= (double)bounds.min.y) && (double)this.min.z <= (double)bounds.max.z) { return((double)this.max.z >= (double)bounds.min.z); } return(false); }
// note that subdivisions will result n^s-1 split (for each s in subdivions) public BSPTreeQuad(BoundsD bounds, Vector3i subdivisions) { Debug.Log("BSPTreeQuad " + bounds); this.bounds = bounds; this.subdivisions = subdivisions; for (int i = 0; i < 3; i++) { Split(i, bounds, subdivisions[i]); } }
public BoundsD ComputeBoundsD() { if (vertices.Count == 0) { return(new BoundsD(Vector3D.zero, Vector3D.zero)); } BoundsD res = new BoundsD(vertices[0].positionD, Vector3D.zero); foreach (var v in vertices) { res.Encapsulate(v.positionD); } return(res); }
public BoundsD GetBoundsD() { if (IsDestroyed()) { Debug.LogWarning("Face is destroyed"); } /*if (!IsValid()) * { * Debug.LogWarning("Face is invalid"); * }*/ BoundsD res = new BoundsD(halfedge.vert.positionD, Vector3D.zero); foreach (var he in Circulate()) { res.Encapsulate(he.vert.positionD); } return(res); }
private void Split(int axis, BoundsD bounds, int subdivisions) { //Debug.Log("Axis " + axis); //Debug.Log("Bounds " + bounds+" path "+path); if (subdivisions <= 0) { return; } Vector3D axisVector = Vector3D.zero; axisVector[axis] = 1; var plane = new Plane3D(axisVector, -bounds.center[axis]); Insert(plane); //Debug.Log("Layer " +layer+ " Insert split " + new Plane3D(axisVector, bounds.center[axis])+" dist to center "+plane.GetDistanceToPoint(bounds.center)); BoundsD left = new BoundsD(bounds.center + (bounds.extents * 0.5), bounds.size * 0.5); // larger BoundsD right = new BoundsD(bounds.center - (bounds.extents * 0.5), bounds.size * 0.5); // smaller Split(axis, left, subdivisions - 1); Split(axis, right, subdivisions - 1); }
/// <summary> /// <para>Grow the bounds to encapsulate the bounds.</para> /// </summary> /// <param name="bounds"></param> public void Encapsulate(BoundsD bounds) { this.Encapsulate(bounds.center - bounds.extents); this.Encapsulate(bounds.center + bounds.extents); }
public void RefreshBounds() { _bounds = FromPath(_scaler.ToPath())._bounds; }