private Point3D findCenter() { var x = Faces.Average(face => face.center.X); var y = Faces.Average(face => face.center.Y); var z = Faces.Average(face => face.center.Z); return(new Point3D(x, y, z)); }
/// <summary> /// Initializes a new instance of the <see cref="Plane" /> class. /// </summary> /// <param name="faces">The faces.</param> public Plane(IEnumerable <PolygonalFace> faces) : base(faces) { //Set the normal by weighting each face's normal with its area //This makes small faces have less effect at shifting the normal var normalSumX = 0.0; var normalSumY = 0.0; var normalSumZ = 0.0; foreach (var face in Faces) { var weightedNormal = face.Normal * face.Area; normalSumX += weightedNormal.X; normalSumY += weightedNormal.Y; normalSumZ += weightedNormal.Z; } Normal = new Vector3(normalSumX, normalSumY, normalSumZ).Normalize(); DistanceToOrigin = Faces.Average(f => Normal.Dot(f.Vertices[0].Coordinates)); }
/// <summary> /// Initializes a new instance of the <see cref="Flat" /> class. /// </summary> /// <param name="faces">The faces.</param> public Flat(IEnumerable <PolygonalFace> faces) : base(faces) { Type = PrimitiveSurfaceType.Flat; //Set the normal by weighting each face's normal with its area //This makes small faces have less effect at shifting the normal var normalSum = new double[3]; foreach (var face in faces) { var weightedNormal = face.Normal.multiply(face.Area); normalSum[0] += weightedNormal[0]; normalSum[1] += weightedNormal[1]; normalSum[2] += weightedNormal[2]; } Normal = normalSum.normalize(3); DistanceToOrigin = Faces.Average(f => Normal.dotProduct(f.Vertices[0].Position, 3)); }
protected override object GetFieldValue(Item cognitiveIndexable) { return((Faces != null && Faces.Length > 0) ? (object)Faces?.Average(x => x.FaceAttributes.Emotion.Fear) : null); }