Find if a point is within a triangle: Difference between revisions

(Added Common Lisp)
Line 283:
; We use the sign of the determinant of vectors (AB,AM), where M(X,Y) is the query point:
; position = sign((Bx - Ax) * (Y - Ay) - (By - Ay) * (X - Ax))
(signsignum (- (* (- (car B) (car A))
(- (cdr P) (cdr A)) )
(* (- (cdr B) (cdr A))
(- (car P) (car A)) ))))
 
 
(defun sign (x)
(if (plusp x)
1
(if (minusp x)
-1
0 )))
</lang>
{{out}}
Line 313 ⟶ 306:
NIL
</pre>
 
 
 
=={{header|D}}==
47

edits