Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void updateEdges() {
- edgeList.clear();
- int n = model.getN();
- int m = model.getM();
- int k = model.getK();
- double a = model.getA();
- double b = model.getB();
- double c = model.getC();
- double d = model.getD();
- Point3D[] lastPointsN = new Point3D[m + 1];
- for (int i = 0; i <= n; i++) {
- double delta = (double)i / n;
- double u = a * (1. - delta) + b * delta;
- Point3D lastPointM = null;
- for (int j = 0; j <= m * k; j++) {
- double dTheta = (double) j / (m * k);
- double v = c * (1. - dTheta) + d * dTheta;
- Point2D.Double p = spline.get(u);
- if (lastPointM == null) {
- lastPointM = new Point3D(
- p.getY() * Math.cos(v),
- p.getY() * Math.sin(v),
- p.getX()
- );
- if (j % k == 0) {
- int index = j / k;
- if (lastPointsN[index] == null) {
- lastPointsN[index] = lastPointM;
- continue;
- }
- edgeList.add(new Edge3D(lastPointsN[index], lastPointM));
- lastPointsN[index] = lastPointM;
- }
- continue;
- }
- Point3D currentPoint = new Point3D(p.getY() * Math.cos(v),
- p.getY() * Math.sin(v),
- p.getX()
- );
- edgeList.add(new Edge3D(lastPointM, currentPoint));
- lastPointM = currentPoint;
- if (j % k == 0) {
- int index = j / k;
- if (lastPointsN[index] == null) {
- lastPointsN[index] = currentPoint;
- continue;
- }
- edgeList.add(new Edge3D(lastPointsN[index], currentPoint));
- lastPointsN[index] = currentPoint;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement