@Override public double getAttributeAsDbl(double t, int semantics, int ordinate) { if (semantics == VertexDescription.Semantics.POSITION) return ordinate == 0 ? getCoord2D(t).x : getCoord2D(t).y; int interpolation = VertexDescription.getInterpolation(semantics); switch (interpolation) { case VertexDescription.Interpolation.NONE: if (t < 0.5) return getStartAttributeAsDbl(semantics, ordinate); else return getEndAttributeAsDbl(semantics, ordinate); case VertexDescription.Interpolation.LINEAR: { double s = getStartAttributeAsDbl(semantics, ordinate); double e = getEndAttributeAsDbl(semantics, ordinate); return MathUtils.lerp(s, e, t); } case VertexDescription.Interpolation.ANGULAR: { throw new GeometryException("not implemented"); } } throw GeometryException.GeometryInternalError(); }
@Override public double getAttributeAsDbl(double t, int semantics, int ordinate) { if (semantics == VertexDescription.Semantics.POSITION) return ordinate == 0 ? getCoord2D(t).x : getCoord2D(t).y; int interpolation = VertexDescription.getInterpolation(semantics); switch (interpolation) { case VertexDescription.Interpolation.NONE: if (t < 0.5) return getStartAttributeAsDbl(semantics, ordinate); else return getEndAttributeAsDbl(semantics, ordinate); case VertexDescription.Interpolation.LINEAR: { double s = getStartAttributeAsDbl(semantics, ordinate); double e = getEndAttributeAsDbl(semantics, ordinate); return MathUtils.lerp(s, e, t); } case VertexDescription.Interpolation.ANGULAR: { throw new GeometryException("not implemented"); } } throw GeometryException.GeometryInternalError(); }
public void setGeometryByValue(Line ln) throws ObjectStreamException { try { attribs = null; if (ln == null) { descriptionBitMask = -1; } VertexDescription vd = ln.getDescription(); descriptionBitMask = vd.m_semanticsBitArray; attribs = new double[vd.getTotalComponentCount() * 2]; attribs[0] = ln.getStartX(); attribs[1] = ln.getStartY(); attribs[2] = ln.getEndX(); attribs[3] = ln.getEndY(); int index = 4; for (int i = 1, n = vd.getAttributeCount(); i < n; i++) { int semantics = vd.getSemantics(i); int comps = VertexDescription.getComponentCount(semantics); for (int ord = 0; ord < comps; ord++) { attribs[index++] = ln.getStartAttributeAsDbl(semantics, ord); attribs[index++] = ln.getEndAttributeAsDbl(semantics, ord); } } } catch (Exception ex) { throw new InvalidObjectException("Cannot serialize this geometry"); } } }
public void setGeometryByValue(Line ln) throws ObjectStreamException { try { attribs = null; if (ln == null) { descriptionBitMask = -1; } VertexDescription vd = ln.getDescription(); descriptionBitMask = vd.m_semanticsBitArray; attribs = new double[vd.getTotalComponentCount() * 2]; attribs[0] = ln.getStartX(); attribs[1] = ln.getStartY(); attribs[2] = ln.getEndX(); attribs[3] = ln.getEndY(); int index = 4; for (int i = 1, n = vd.getAttributeCount(); i < n; i++) { int semantics = vd.getSemantics(i); int comps = VertexDescription.getComponentCount(semantics); for (int ord = 0; ord < comps; ord++) { attribs[index++] = ln.getStartAttributeAsDbl(semantics, ord); attribs[index++] = ln.getEndAttributeAsDbl(semantics, ord); } } } catch (Exception ex) { throw new InvalidObjectException("Cannot serialize this geometry"); } } }