Skip to main content

functions - Module and Local variable


Hello,


GetIntersectionPoint[p1_, p2_] := 
Module[{pts, vecs, n, vars, distance, sol, x, y, z, t}, (


pts = p2;
vecs = p1 - pts;
n = Length[pts];
vars = Array[t, n];
{distance, sol} =
Minimize[
Total[({x, y, z} - Transpose[pts + vecs vars])^2, 2], {x, y, z}~
Join~vars]



)]

I call this function with p1 and p2 where


    p1={{100, 100, 100},{100, 0, 100},{0, 100, 100}};
p2={{500/3, 500/3, 0},{500/3, 0, 0},{0, 500/3, 0}};

I obtain like this:


{0, {x$17013 -> 0, y$17013 -> 0, z$17013 -> 250, t$17013[1] -> 5/2, 
t$17013[2] -> 5/2, t$17013[3] -> 5/2}}


How Can I fix the rename of the local variables ?




Comments