Planning to build some geometry module to do various calculations.

here goes some line functions

-module(lineFunc). -compile(export_all). % This function takes line of form Ax + By + C = 0; lineFunc(Ax,By,C) -> {fun(Y) -> - (By * Y + C)/Ax end, fun(X) -> -(Ax * X + C )/By end}. % Gives two functions to find value at various points ,Xintercept, Yintercept and Slope make_line(A,B,C) -> Xintercept = case A of 0 -> infinity; A-> -C / A end, Yintercept = case B of 0 -> infinity; B -> -C / B end, Slope = (Yintercept - 0 )/ (0 - Xintercept), {XatY, YatX } = lineFunc(A,B,C), [XatY,YatX,Xintercept,Yintercept,Slope]. %%line_inequality(A,B,C,Symbol) -> %% fun(X,Y) -> line_intersection([_,_,X,Y,S1], [_,_,Xd,Yd, S2]) -> case S1 of S2 -> {parallel_lines}; S1 -> Deno = (Y*Xd - X * Yd), {( X*Y*Xd - X * Xd * Yd)/ Deno, ( - X* Y * Yd+ Y * Xd * Yd)/ Deno} end

Advertisements