use of org.fxyz.geometry.Point3D in project FXyzLib by Birdasaur.
the class SpringHelper method getS.
public Point3D getS(int t, float cu, float su) {
Point3D[] trihedron = trihedrons.get(t);
// S[t,u]
Point3D p = trihedron[SpringHelper.tR].add(trihedron[SpringHelper.tN].multiply(cu).add(trihedron[SpringHelper.tB].multiply(su)));
// [0-<=2Pi]
p.f = ((float) (t * arc) / (float) subDivLength);
return p;
}
use of org.fxyz.geometry.Point3D in project FXyzLib by Birdasaur.
the class Text3DHelper method getPoints.
private void getPoints(PathElement elem) {
if (elem instanceof MoveTo) {
list = new ArrayList<>();
p0 = new Point3D((float) ((MoveTo) elem).getX(), (float) ((MoveTo) elem).getY(), 0f);
list.add(p0);
} else if (elem instanceof LineTo) {
list.add(new Point3D((float) ((LineTo) elem).getX(), (float) ((LineTo) elem).getY(), 0f));
} else if (elem instanceof CubicCurveTo) {
Point3D ini = (list.size() > 0 ? list.get(list.size() - 1) : p0);
IntStream.rangeClosed(1, POINTS_CURVE).forEach(i -> list.add(evalCubicBezier((CubicCurveTo) elem, ini, ((double) i) / POINTS_CURVE)));
} else if (elem instanceof QuadCurveTo) {
Point3D ini = (list.size() > 0 ? list.get(list.size() - 1) : p0);
IntStream.rangeClosed(1, POINTS_CURVE).forEach(i -> list.add(evalQuadBezier((QuadCurveTo) elem, ini, ((double) i) / POINTS_CURVE)));
} else if (elem instanceof ClosePath) {
list.add(p0);
// stored in a LineSegment: a continuous line that can change direction
if (Math.abs(getArea()) > 0.001) {
LineSegment line = new LineSegment(text);
line.setHole(isHole());
line.setPoints(list);
line.setPath(generatePath());
line.setOrigen(p0);
polis.add(line);
}
}
}
use of org.fxyz.geometry.Point3D in project FXyzLib by Birdasaur.
the class WeightedPoint method updatePhysics.
public void updatePhysics(double dt, double t) {
synchronized (this) {
if (isAnchored()) {
setPosition(getAnchorPosition());
return;
}
Point3D vel = new Point3D((position.x - oldPosition.x), (position.y - oldPosition.y), (position.z - oldPosition.z));
float dtSq = (float) (dt * dt);
// calculate the next position using Verlet Integration
Point3D next = new Point3D(position.x + (vel.x + (((force.x / (float) (mass)) * 0.5f) * dtSq)), position.y + (vel.y + (((force.y / (float) (mass)) * 0.5f) * dtSq)), position.z + (vel.z + (((force.z / (float) (mass)) * 0.5f) * dtSq)));
// reset variables
setOldPosition(position);
setPosition(next);
clearForces();
// log.log(Level.INFO, "\n Velocity: {0}", vel);
}
}
Aggregations