Reputation: 3837
using Microsoft.DirectX.Direct3D;
struct Voxel
{
public Vector3 p
public Voxel(float _x, float _y, float _z)
{
p = new Vector3(_x, _y, _z);
}
}
List<Voxel> myDataList = new List<Voxel>();
After some add data method, then i finally get myDataList
to have something like below:
myDataList[0] - { X: 164 , Y: 59 , Z: 120 }
myDataList[1] - { X: 146 , Y: 63 , Z: 120 }
myDataList[2] - { X: 192 , Y: 59 , Z: 120 }
myDataList[3] - { X: 196 , Y: 79 , Z: 120 } //peak coordinate is here
myDataList[4] - { X: 110 , Y: 55 , Z: 120 }
In the above example, myDataList[3] is the peak coordinate where it has the highest Y value, which is 79.
My question is, how can I get to identify that myDataList[3] is the peak coordinate where it contain the highest Y value?
I know I can do something like below to get the max Y value
float maxY = myDataList.Max(y => y.p.Y); //output = 79
But what I want is the 3D coordinate (X, Y, Z) instead of just knowing the maxY
*Do not order the list by descending w.r.t Y value and .First()
, because the order of myDataList does matter in my next proceeding step.
Upvotes: 3
Views: 156
Reputation: 63065
since you already have maxY
you can use that value to find max Voxel
like below
var maxVoxel = myDataList.FirstOrDefault(x=>x.p.Y ==maxY);
Upvotes: 2