summaryrefslogtreecommitdiffstats
path: root/AutoVisual
diff options
context:
space:
mode:
Diffstat (limited to 'AutoVisual')
-rw-r--r--AutoVisual/IGPFamily.pde37
1 files changed, 37 insertions, 0 deletions
diff --git a/AutoVisual/IGPFamily.pde b/AutoVisual/IGPFamily.pde
index 3108686..4d05542 100644
--- a/AutoVisual/IGPFamily.pde
+++ b/AutoVisual/IGPFamily.pde
@@ -164,6 +164,43 @@ class IGPFamily {
translate(mid.x*(-1), mid.y*(-1));
}
+ PVector lineIntersection(PVector p1, PVector p2, PVector p3, PVector p4) {
+ PVector b = PVector.sub(p2, p1);
+ PVector d = PVector.sub(p4, p3);
+
+ float b_dot_d_perp = b.x * d.y - b.y * d.x;
+ if (b_dot_d_perp == 0) {
+ return null;
+ }
+
+ PVector c = PVector.sub(p3, p1);
+ float t = (c.x * d.y - c.y * d.x) / b_dot_d_perp;
+ if (t < 0 || t > 1) { return null; }
+ float u = (c.x * b.y - c.y * b.x) / b_dot_d_perp;
+ if (u < 0 || u > 1) { return null; }
+
+ return new PVector(p1.x+t*b.x, p1.y+t*b.y);
+ }
+
+ float angleBetweenTwoVectors (PVector p1, PVector p2) {
+ float angle = atan2(p1.y-p2.y, p1.x-p2.x);
+ if (angle < 0) {
+ angle+=TWO_PI;
+ }
+ return degrees(angle);
+ }
+
+ PVector extendLine(PVector startPoint, PVector endPoint, float boundary, boolean vertical){
+ float m,n;
+ m = (endPoint.y-startPoint.y)/(endPoint.x-startPoint.x);
+ n = endPoint.y-m*endPoint.x;
+ if (vertical){
+ return new PVector((boundary-n)/m, boundary);
+ } else {
+ return new PVector(boundary, (m*boundary)+n);
+ }
+ }
+
void display() {
createAlphaCircle();
}