Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

10
LINES

< > BotCompany Repo | #1035466 // lineIntersectionPt

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (8142L) is out of date.

static DoublePt lineIntersectionPt(LineThroughPoint l1, LineThroughPoint l2) {
  DoublePt p1 = doublePt(l1.x, l1.y), p2 = l1.pointOnLine(1);
  DoublePt p3 = doublePt(l2.x, l2.y), p4 = l2.pointOnLine(1);
  double d = (p1.x-p2.x)*(p3.y-p4.y)-(p1.y-p2.y)*(p3.x-p4.x);
  double x = ((p1.x*p2.y-p1.y*p2.x)*(p3.x-p4.x)
    -(p1.x-p2.x)*(p3.x*p4.y-p3.y*p4.x))/d;
  double y = ((p1.x*p2.y-p1.y*p2.x)*(p3.y-p4.y)
    -(p1.y-p2.y)*(p3.x*p4.y-p3.y*p4.x))/d;
  ret doublePt(x, y);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035466
Snippet name: lineIntersectionPt
Eternal ID of this version: #1035466/4
Text MD5: af97f69e6bef40ccf36b4557241ce87f
Author: stefan
Category: javax / math
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-21 19:04:24
Source code size: 479 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 155 / 199
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)