-2

I have two points(in two dimension) and I want to divide the distance between them to n part with same length, I was thinking about doing this manually by using for, but because it is numerical it wont be precise, so is there any way to do this? any help is appreciated.

negar
  • 45
  • So just to clarify, what exactly do you want as a result? $n$ points in two dimensions, that essentially form a line between the two input points? – Matti P. Feb 05 '21 at 13:39
  • yes, n points on this line which each two adjacent point has same distance. I want to have a matrix which these points are in it. – negar Feb 05 '21 at 13:43

1 Answers1

1

In your original question you wrote, "n part with same length", which implies n+1 equispaced points and n equal segments between them.

In your followup comment you wrote "n points", which implies n-1 equal spaces between them.

It's now unclear which you actually want.

p1:=[2,4]:
p2:=[6,1]:

n:=7:

n equal distances

S1:=Matrix([seq(p1+(p2-p1)*(i-1)/(n), i=1..n+1)]);

plot(S1, style=pointline, symbolsize=20, symbol=solidcircle);

n equispaced points

S2:=Matrix([seq(p1+(p2-p1)*(i-1)/(n-1), i=1..n)]);

plot(S2, style=pointline, symbolsize=20, symbol=solidcircle);

acer
  • 5,293
  • thank you so much. can we do this on a diagram we get from a mathematical function either? (not on a line between two point, I hope I could tell what I mean) – negar Feb 05 '21 at 22:04
  • I mean doing this on the curve and then get a matrix which each point is on diagram. – negar Feb 05 '21 at 22:11
  • Are you now asking about splitting a curve into pieces according to (equal) arclength? If so then why mention "mathematical function" without telling us what it is? Is it secret? – acer Feb 08 '21 at 22:00