Skip to main content
2 of 2
Added a simplification.
N.J.Evans
  • 5.1k
  • 21
  • 26

Here's how I'd do it. Starting with diffcoord

diffcoord = {{2.87796, 29.2153}, {-13.6571, -19.1573}, {2.9201, 
  8.7201}, {3.52192, -16.1424}, {0.53561, 19.1832}, {3.76663, 
  3.32865}, {-11.0295, -10.1585}, {14.9637, 
  19.0262}, {-12.4468, -28.5079}};

Pair each element with the next and Dot the pairs.

Dot@@@(Transpose@{diffcoord[[1;;-2]],diffcoord[[2;;-1]]})

The output is

{-598.991, -206.934, -130.479, -307.777, 65.8716, -75.3581, -358.32,
-728.647}

There is certainly a more clever way to combine the two if you need to do this on huge lists, but this makes sense to me.

Edit: @Guess who it is reminded me that Partition has a 3rd argument to specify an offset, which makes this a lot nicer looking!

Dot@@@Partition[diffcoord,2,1]
N.J.Evans
  • 5.1k
  • 21
  • 26