/** @return */ public WB_Plane getPlane() { WB_Coord fn = getFaceNormal(); if (WB_Vector.getSqLength3D(fn) < 0.5) { if (WB_Epsilon.isEqualAbs(_halfedge.getVertex().xd(), _halfedge.getEndVertex().xd())) { fn = new WB_Vector(1, 0, 0); } else { fn = new WB_Vector(0, 0, 1); } } return new WB_Plane(getFaceCenter(), fn); }
/** @return */ public WB_Coord getNonNormFaceNormal() { if (_halfedge == null) { return null; } // calculate normal with Newell's method HE_Halfedge he = _halfedge; final WB_Vector _normal = new WB_Vector(); HE_Vertex p0; HE_Vertex p1; do { p0 = he.getVertex(); p1 = he.getNextInFace().getVertex(); _normal.addSelf( (p0.yd() - p1.yd()) * (p0.zd() + p1.zd()), (p0.zd() - p1.zd()) * (p0.xd() + p1.xd()), (p0.xd() - p1.xd()) * (p0.yd() + p1.yd())); he = he.getNextInFace(); } while (he != _halfedge); return _normal; }
/** @return */ public double getFaceArea() { if (_halfedge == null) { return 0; } final WB_Coord n = getFaceNormal(); if (WB_Vector.getLength3D(n) < 0.5) { return 0; } final double x = WB_Math.fastAbs(n.xd()); final double y = WB_Math.fastAbs(n.yd()); final double z = WB_Math.fastAbs(n.zd()); double area = 0; int coord = 3; if ((x >= y) && (x >= z)) { coord = 1; } else if ((y >= x) && (y >= z)) { coord = 2; } HE_Halfedge he = _halfedge; do { switch (coord) { case 1: area += (he.getVertex().yd() * (he.getNextInFace().getVertex().zd() - he.getPrevInFace().getVertex().zd())); break; case 2: area += (he.getVertex().xd() * (he.getNextInFace().getVertex().zd() - he.getPrevInFace().getVertex().zd())); break; case 3: area += (he.getVertex().xd() * (he.getNextInFace().getVertex().yd() - he.getPrevInFace().getVertex().yd())); break; } he = he.getNextInFace(); } while (he != _halfedge); switch (coord) { case 1: area *= (0.5 / x); break; case 2: area *= (0.5 / y); break; case 3: area *= (0.5 / z); } return WB_Math.fastAbs(area); }
/** @return */ public boolean isDegenerate() { return WB_Vector.getLength3D(getFaceNormal()) < 0.5; }