I am creating a polymer(where each monomer is of equal length) using this method:
angles = RandomVariate[NormalDistribution[0, 0.2], 40];
a1 = 1;
anglePath1[angles_, a_] := FoldList[# + a {Cos@#2, Sin@#2} &, {0, 0}, Accumulate@angles]
p1 = anglePath1[angles, a1];
Then, I use SplineFit
Needs["Splines`"];
spt = SplineFit[p1, Cubic];
lt = spt[[2, -1]];
Then, I break the polymer into monomer of equal length. To do so, I calculate the arc length of the polymer:
dz = .0000001;
arc = NIntegrate[Norm[(spt[z + dz] - spt[z])/dz], {z, 0, lt}]
mesh = Solve [arc/a1 == div];
meshf = Round[div /. mesh];
After this I extract co-ordinates:
plot = ParametricPlot[spt[t], {t, 0, lt},
MeshFunctions -> {"ArcLength"}, Mesh -> {meshf[[1]]},
MeshStyle -> {PointSize[0.01], Red}]
coord = Cases[Normal@plot, Point[p_] :> p, Infinity];
So, now I calculate distance between each points:
(*distance calculated using initially created co-ordinates*)
Norm /@ Differences@p1
(*distance calculated using co-ordinates grabbed from spline fitted curve*)
Norm /@ Differences@coord
These two distances are different and I don't understand why.
The method calculating arc length and grabbing co-ordinates are from @MichaelE2 answer from this post:
angleshould probably be calledangles, as you show in use further down when you definep1. Further, theSplineFitdoesn't work becauseiis not defined. Please past back the code you post in a clean mathematica session and make the necessary modifications until it runs. – MarcoB Jun 18 '15 at 19:17