private bool ClosestPointTo(PlanktonXYZ point, ref float t) { bool rc = false; PlanktonXYZ D = m_to - m_from; float DoD = (D.X * D.X + D.Y * D.Y + D.Z * D.Z); if (DoD > 0f) { if (point.DistanceTo(m_from) <= point.DistanceTo(m_to)) { t = ((point - m_from) * D) / DoD; } else { t = 1f + ((point - m_to) * D) / DoD; } rc = true; } return rc; }
public float ClosestParameter(PlanktonXYZ point) { float t = 0; PlanktonXYZ D = m_to - m_from; float DoD = (D.X * D.X + D.Y * D.Y + D.Z * D.Z); if (DoD > 0f) { if (point.DistanceTo(m_from) <= point.DistanceTo(m_to)) { t = ((point - m_from) * D) / DoD; } else { t = 1f + ((point - m_to) * D) / DoD; } } else { t = 0f; } return t; }