//{----------------------------------------------------------} //{ Interpolate the position where an metaballs intersects } //{ the line betweenthe two coordicates, C1 and C2 } //{----------------------------------------------------------} internal void Interpolate(TGridPoint C1, TGridPoint C2, out TGLCoord CResult, out TGLCoord Norm) { float mu = 0; if (Math.Abs(C1.Value) == 1) { CResult = C1.Pos; Norm = C1.Normal; } else if (Math.Abs(C2.Value) == 1) { CResult = C2.Pos; Norm = C2.Normal; } else if (C1.Value == C2.Value) { CResult = C1.Pos; Norm = C1.Normal; } else { mu = (1 - C1.Value) / (C2.Value - C1.Value); CResult.X = C1.Pos.X + mu * (C2.Pos.X - C1.Pos.X); CResult.Y = C1.Pos.Y + mu * (C2.Pos.Y - C1.Pos.Y); CResult.Z = C1.Pos.Z + mu * (C2.Pos.Z - C1.Pos.Z); Norm.X = C1.Normal.X + (C2.Normal.X - C1.Normal.X) * mu; Norm.Y = C1.Normal.Y + (C2.Normal.Y - C1.Normal.Y) * mu; Norm.Z = C1.Normal.Z + (C2.Normal.Z - C1.Normal.Z) * mu; } }
public TGridCube(int count) : this() { GridPoint = new TGridPoint[8]; }