I've been working on a rather simple implimination of parameterizing a 3D line in space, and now am trying to find a way to map different values of t over those equations. The only approaches I've tried so far have a lot of negative side effects and complications. Advice is appreciated because I need to find the points on a lot of lines by segmentation. :) Thanks.

 {u,i} = {{2099,1313,4599},{-21208,-1146,4697}}

 f[x] = (i[[1]]-u[[1]]) t + u[[1]];
 f[y] = (i[[2]]-u[[2]]) t + u[[2]];
 f[z] = (i[[3]]-u[[3]]) t + u[[3]];

 {f[x],f[y],f[z]} /. t->.5
  • $\begingroup$ The expressions f[x]=, f[y]=, and f[z]= are syntactically correct but are not customary. In any case, can you give some examples of the negative side effects you want to avoid? $\endgroup$
    – Hector
    Commented Jul 28, 2018 at 20:37
  • $\begingroup$ Well briefly... one side effect is that I don't know exactly how to do that? (As you could probably already tell from my non-customary expression.) Perhaps someone will enlighten me as to the standard way to express these terms in their answer? $\endgroup$
    – BBirdsell
    Commented Jul 28, 2018 at 21:35
  • 1
    $\begingroup$ As you do not use x as a argument of the function, but f[x] is just a name you could jist write fx=, fy=, fz=. $\endgroup$
    – Johu
    Commented Jul 28, 2018 at 21:45

1 Answer 1


I set values of t to be from 1,2,...10 using Range

{u, i} = {{2099, 1313, 4599}, {-21208, -1146, 4697}};

f[x] = (i[[1]] - u[[1]]) t + u[[1]];
f[y] = (i[[2]] - u[[2]]) t + u[[2]];
f[z] = (i[[3]] - u[[3]]) t + u[[3]];

{fNumericX, fNumericY, fNumericZ} = {f[x], f[y], f[z]} /. t -> Range[1, 10]

Your expression works if t should be a vector. The values of each coordinate are saved as vectors in fNumericX, fNumericY, and fNumericZ

In more complex cases it might not work and and you might want to look up how Map and Table could be used for the same purpose.

Somewhat more elegant code for solving the same task using Map

{fNumericX, fNumericY, fNumericZ} = 
 Transpose@Map[(t \[Function] (i - u) t + u), Range[1, 10]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.