// Basic point object - makes the Line and Spring class independant of the Particle object static class Point{ float x, y; // Constructor Point(float x, float y){ this.x = x; this.y = y; } // Set a new position void setPosition(float x, float y){ this.x = x; this.y = y; } // Copy this object Point copy(Point a){ return new Point(a.x, a.y); } // Subtract one position from another void minus(Point o){ x -= o.x; y -= o.y; } // Add one position to another void plus(Point o){ x += o.x; y += o.y; } // Scale a position void mul(float n){ x *= n; y *= n; } // Some methods I find easier to read as static // Get the distance between two points static float dist(Point a, Point b){ return sqrt((b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y)); } // Get a Point between Point a and b static Point lerp(Point a, Point b, float n){ return(new Point((a.x + b.x) * n, (a.y + b.y) * n)); } }