Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SphericBezier extends AbstractNode {
- private Vector a;
- private Vector b;
- public SphericBezier(Vector position , Vector end, Vector a , Vector b ) {
- super(position , end);
- this.a = a;
- this.b = b;
- }
- public void reCalculate() {
- Vector last ;
- Vector v ;
- double l = 0;
- last = getFirst().clone();
- float jump = (float) 1/getPrecision();
- for (int j = 0 ; j <= getPrecision() ; j++) {
- v = calculate(jump+j);
- l += last.distance(v);
- setLength(l);
- }
- }
- public Vector calculate(float range) {
- //t = 1-range
- float t = 1-range;
- //p-0
- Vector v = getFirst().clone();
- v.multiply(Math.pow(t, 3));
- //p-1
- Vector c = a.clone();
- c.multiply(3*Math.pow(t, 2)*range);
- v.add(c);
- //p-2
- c = b.clone();
- c.multiply(3*Math.pow(t, 2)*Math.pow(range, 2));
- v.add(c);
- //p-3
- c = getLast().clone();
- c.multiply(Math.pow(range, 3));
- v.add(c);
- return v;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement