Applying a Function to a Matrix/List?

Hello,

I want to calculate the centroids of a quadrilateral moving in space using

RegionCentroid[Polygon[{{p1x,p1y,p1z,},{p2x,p2y,p2z,},{p3x,p3y,p3z,},{p4x,p4y,p4z,}}]

p1…p4 are the corners of the quadrilateral. The coordinates are given in a excel spreadsheet with p1x p1y … p4z in the columns. every row gives the coordinate at a different moment.
Has someone an advice how to apply this RegionCentroid function to the spreadsheet giving me the list of the centroids at the different moments.

I hope you can help me :slight_smile:

First import:

data = Import["myfile.xls"]

where the table in each Excel file sheet becomes a matrix in data’s outermost list.

Then slice and feed:

RegionCentroid[Polygon[Partition[#, 3]]] & /@ First[data]

where I assumed that your data of interest is on the first sheet. Partition[#, 3]& slices lists into chunks of length 3. You may want to read up on anonymous aka pure functions for the ‘#’ and ‘&’ in this and on Map (short notation /@ ).

Hope this helps,
Peter

Thank your very much for this answer! Your code fixed my issue :). I am going to learn this partition, and # @ stuff!

Grateful Greetings!