Skip to content

Instantly share code, notes, and snippets.

@thu0x31
Last active May 24, 2022 22:50
Show Gist options
  • Save thu0x31/25d72b5ee5fd429b911c997ac930ce4c to your computer and use it in GitHub Desktop.
Save thu0x31/25d72b5ee5fd429b911c997ac930ce4c to your computer and use it in GitHub Desktop.

Revisions

  1. thu0x31 revised this gist May 21, 2022. 2 changed files with 15 additions and 0 deletions.
    File renamed without changes.
    15 changes: 15 additions & 0 deletions intersectionTwoCiclesRight.vfl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    // http://paulbourke.net/geometry/circlesphere/ Intersection of two circles
    function vector intersectionTwoCiclesRight(vector p0, p1; float radius0, radius1) {
    float d = distance(p0, p1);
    float a = (radius0 * radius0 - radius1 * radius1 + d * d) / (2*d);
    float h = sqrt(radius0 * radius0 - a * a);

    vector p2 = p0 + a * (p1 - p0) / d;

    // xz
    return set(
    p2.x + h*(p1.z - p0.z)/d,
    p2.y,
    p2.z - h*(p1.x - p0.x)/d
    );
    }
  2. thu0x31 created this gist May 21, 2022.
    15 changes: 15 additions & 0 deletions intersectionTwoCicles.vfl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    // http://paulbourke.net/geometry/circlesphere/ Intersection of two circles
    function vector intersectionTwoCiclesLeft(vector p0, p1; float radius0, radius1) {
    float d = distance(p0, p1);
    float a = (radius0 * radius0 - radius1 * radius1 + d * d) / (2*d);
    float h = sqrt(radius0 * radius0 - a * a);

    vector p2 = p0 + a * (p1 - p0) / d;

    // xz
    return set(
    p2.x - h*(p1.z - p0.z)/d,
    p2.y,
    p2.z + h*(p1.x - p0.x)/d
    );
    }