本文整理汇总了C#中Orbit.getPositionAtUT方法的典型用法代码示例。如果您正苦于以下问题:C# Orbit.getPositionAtUT方法的具体用法?C# Orbit.getPositionAtUT怎么用?C# Orbit.getPositionAtUT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orbit
的用法示例。
在下文中一共展示了Orbit.getPositionAtUT方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateSolarForce
// Calculate solar force as function of
// sail, orbit, transform, and UT
public static Vector3d CalculateSolarForce(SolarSailPart sail, Orbit orbit, Vector3d normal, double UT)
{
if (sail.part != null) {
Vector3d sunPosition = FlightGlobals.Bodies[0].getPositionAtUT(UT);
Vector3d ownPosition = orbit.getPositionAtUT(UT);
Vector3d ownsunPosition = ownPosition - sunPosition;
// If normal points away from sun, negate so our force is always away from the sun
// so that turning the backside towards the sun thrusts correctly
if (Vector3d.Dot (normal, ownsunPosition) < 0) {
normal = -normal;
}
// Magnitude of force proportional to cosine-squared of angle between sun-line and normal
double cosConeAngle = Vector3.Dot (ownsunPosition.normalized, normal);
Vector3d force = normal * cosConeAngle * cosConeAngle * sail.surfaceArea * sail.reflectedPhotonRatio * solarForceAtDistance(sunPosition, ownPosition);
return force;
} else {
return Vector3d.zero;
}
}
示例2: inSun
// Test if an orbit at UT is in sunlight
public static bool inSun(Orbit orbit, double UT)
{
Vector3d a = orbit.getPositionAtUT(UT);
Vector3d b = FlightGlobals.Bodies[0].getPositionAtUT(UT);
foreach (CelestialBody referenceBody in FlightGlobals.Bodies) {
if (referenceBody.flightGlobalsIndex == 0) { // the sun should not block line of sight to the sun
continue;
}
Vector3d refminusa = referenceBody.getPositionAtUT(UT) - a;
Vector3d bminusa = b - a;
if (Vector3d.Dot(refminusa, bminusa) > 0) {
if (Vector3d.Dot(refminusa, bminusa.normalized) < bminusa.magnitude) {
Vector3d tang = refminusa - Vector3d.Dot(refminusa, bminusa.normalized) * bminusa.normalized;
if (tang.magnitude < referenceBody.Radius) {
return false;
}
}
}
}
return true;
}
示例3: ApplyVesselUpdate
//.........这里部分代码省略.........
//DarkLog.Debug("Skipping update, physics held");
return;
}
//Don't set the position while the vessel is unpacking / loading - It doesn't apply properly.
if (isUnpacking || isLoading)
{
//DarkLog.Debug("Skipping update, isUnpacking: " + isUnpacking + " isLoading: " + isLoading);
return;
}
if (updateVessel.packed)
{
updateVessel.latitude = update.position[0];
updateVessel.longitude = update.position[1];
updateVessel.altitude = update.position[2];
if (!updateVessel.LandedOrSplashed)
{
//Not landed but under 10km.
Vector3d orbitalPos = updatePostion - updateBody.position;
Vector3d surfaceOrbitVelDiff = updateBody.getRFrmVel(updatePostion);
Vector3d orbitalVel = updateVelocity + surfaceOrbitVelDiff;
updateVessel.orbitDriver.orbit.UpdateFromStateVectors(orbitalPos.xzy, orbitalVel.xzy, updateBody, Planetarium.GetUniversalTime());
updateVessel.orbitDriver.pos = updateVessel.orbitDriver.orbit.pos.xzy;
updateVessel.orbitDriver.vel = updateVessel.orbitDriver.orbit.vel;
/*
DarkLog.Debug("updateVelocity: " + (Vector3)updateVelocity + ", |vel| " + updateVelocity.magnitude);
DarkLog.Debug("surfaceOrbitVelDiff: " + (Vector3)surfaceOrbitVelDiff + ", |vel| " + surfaceOrbitVelDiff.magnitude);
*/
/*
if (HighLogic.LoadedScene == GameScenes.FLIGHT && FlightGlobals.fetch.activeVessel != null)
{
DarkLog.Debug("ourVel: " + (Vector3)FlightGlobals.fetch.activeVessel.orbitDriver.vel + ", |vel| " + updateVessel.orbitDriver.vel.magnitude);
}
DarkLog.Debug("theirVel: " + (Vector3)updateVessel.orbitDriver.vel + ", |vel| " + updateVessel.orbitDriver.vel.magnitude);
*/
}
}
else
{
Vector3d velocityOffset = updateVelocity - updateVessel.srf_velocity;
updateVessel.SetPosition(updatePostion, true);
updateVessel.ChangeWorldVelocity(velocityOffset);
}
}
else
{
Orbit updateOrbit = new Orbit(update.orbit[0], update.orbit[1], update.orbit[2], update.orbit[3], update.orbit[4], update.orbit[5], update.orbit[6], updateBody);
updateOrbit.Init();
updateOrbit.UpdateFromUT(Planetarium.GetUniversalTime());
if (updateVessel.packed)
{
//The OrbitDriver update call will set the vessel position on the next fixed update
CopyOrbit(updateOrbit, updateVessel.orbitDriver.orbit);
updateVessel.orbitDriver.pos = updateVessel.orbitDriver.orbit.pos.xzy;
updateVessel.orbitDriver.vel = updateVessel.orbitDriver.orbit.vel;
}
else
{
//Vessel.SetPosition is full of fun and games. Avoid at all costs.
//Also, It's quite difficult to figure out the world velocity due to Krakensbane, and the reference frame.
Vector3d posDelta = updateOrbit.getPositionAtUT(Planetarium.GetUniversalTime()) - updateVessel.orbitDriver.orbit.getPositionAtUT(Planetarium.GetUniversalTime());
Vector3d velDelta = updateOrbit.getOrbitalVelocityAtUT(Planetarium.GetUniversalTime()).xzy - updateVessel.orbitDriver.orbit.getOrbitalVelocityAtUT(Planetarium.GetUniversalTime()).xzy;
//Vector3d velDelta = updateOrbit.vel.xzy - updateVessel.orbitDriver.orbit.vel.xzy;
updateVessel.Translate(posDelta);
updateVessel.ChangeWorldVelocity(velDelta);
}
}
//Angular velocity
Vector3 angularVelocity = new Vector3(update.angularVelocity[0], update.angularVelocity[1], update.angularVelocity[2]);
if (updateVessel.parts != null)
{
Vector3 newAng = updateVessel.ReferenceTransform.rotation * angularVelocity;
foreach (Part vesselPart in updateVessel.parts)
{
if (vesselPart.rb != null && !vesselPart.rb.isKinematic && vesselPart.State == PartStates.ACTIVE)
{
//The parts can have different rotations - This transforms them into the root part direction which is where the angular velocity is transferred.
vesselPart.rb.angularVelocity = (Quaternion.Inverse(updateVessel.rootPart.rb.rotation) * vesselPart.rb.rotation) * newAng;
}
}
}
//Flight state controls (Throttle etc)
if (!isSpectating)
{
updateVessel.ctrlState.CopyFrom(update.flightState);
}
else
{
FlightInputHandler.state.CopyFrom(update.flightState);
}
//Action group controls
updateVessel.ActionGroups.SetGroup(KSPActionGroup.Gear, update.actiongroupControls[0]);
updateVessel.ActionGroups.SetGroup(KSPActionGroup.Light, update.actiongroupControls[1]);
updateVessel.ActionGroups.SetGroup(KSPActionGroup.Brakes, update.actiongroupControls[2]);
updateVessel.ActionGroups.SetGroup(KSPActionGroup.SAS, update.actiongroupControls[3]);
updateVessel.ActionGroups.SetGroup(KSPActionGroup.RCS, update.actiongroupControls[4]);
}
示例4: Apply
//.........这里部分代码省略.........
updateVessel.protoVessel.altitude = altitude;
if (updateVessel.packed)
{
if (!updateVessel.LandedOrSplashed)
{
//Not landed but under 10km.
Vector3d orbitalPos = updatePostion - updateBody.position;
Vector3d surfaceOrbitVelDiff = updateBody.getRFrmVel(updatePostion);
Vector3d orbitalVel = updateVelocity + surfaceOrbitVelDiff;
updateVessel.orbitDriver.orbit.UpdateFromStateVectors(orbitalPos.xzy, orbitalVel.xzy, updateBody, Planetarium.GetUniversalTime());
updateVessel.orbitDriver.pos = updateVessel.orbitDriver.orbit.pos.xzy;
updateVessel.orbitDriver.vel = updateVessel.orbitDriver.orbit.vel;
}
}
else
{
Vector3d velocityOffset = updateVelocity - updateVessel.srf_velocity;
updateVessel.SetPosition(updatePostion, true);
updateVessel.ChangeWorldVelocity(velocityOffset);
}
}
else
{
Orbit updateOrbit = new Orbit(orbit[0], orbit[1], orbit[2], orbit[3], orbit[4], orbit[5], orbit[6], updateBody);
updateOrbit.Init();
updateOrbit.UpdateFromUT(Planetarium.GetUniversalTime());
double latitude = updateBody.GetLatitude(updateOrbit.pos);
double longitude = updateBody.GetLongitude(updateOrbit.pos);
double altitude = updateBody.GetAltitude(updateOrbit.pos);
updateVessel.latitude = latitude;
updateVessel.longitude = longitude;
updateVessel.altitude = altitude;
updateVessel.protoVessel.latitude = latitude;
updateVessel.protoVessel.longitude = longitude;
updateVessel.protoVessel.altitude = altitude;
if (updateVessel.packed)
{
//The OrbitDriver update call will set the vessel position on the next fixed update
VesselUtil.CopyOrbit(updateOrbit, updateVessel.orbitDriver.orbit);
updateVessel.orbitDriver.pos = updateVessel.orbitDriver.orbit.pos.xzy;
updateVessel.orbitDriver.vel = updateVessel.orbitDriver.orbit.vel;
}
else
{
//Vessel.SetPosition is full of fun and games. Avoid at all costs.
//Also, It's quite difficult to figure out the world velocity due to Krakensbane, and the reference frame.
Vector3d posDelta = updateOrbit.getPositionAtUT(Planetarium.GetUniversalTime()) - updateVessel.orbitDriver.orbit.getPositionAtUT(Planetarium.GetUniversalTime());
Vector3d velDelta = updateOrbit.getOrbitalVelocityAtUT(Planetarium.GetUniversalTime()).xzy - updateVessel.orbitDriver.orbit.getOrbitalVelocityAtUT(Planetarium.GetUniversalTime()).xzy;
//Vector3d velDelta = updateOrbit.vel.xzy - updateVessel.orbitDriver.orbit.vel.xzy;
updateVessel.Translate(posDelta);
updateVessel.ChangeWorldVelocity(velDelta);
}
}
//Rotation
Quaternion unfudgedRotation = new Quaternion(rotation[0], rotation[1], rotation[2], rotation[3]);
Quaternion updateRotation = normalRotate * unfudgedRotation;
updateVessel.SetRotation(updateVessel.mainBody.bodyTransform.rotation * updateRotation);
if (updateVessel.packed)
{
updateVessel.srfRelRotation = updateRotation;
updateVessel.protoVessel.rotation = updateVessel.srfRelRotation;
}
//Angular velocity
//Vector3 angularVelocity = new Vector3(this.angularVelocity[0], this.angularVelocity[1], this.angularVelocity[2]);
if (updateVessel.parts != null)
{
//Vector3 newAng = updateVessel.ReferenceTransform.rotation * angularVelocity;
foreach (Part vesselPart in updateVessel.parts)
{
if (vesselPart.rb != null && !vesselPart.rb.isKinematic && vesselPart.State == PartStates.ACTIVE)
{
//The parts can have different rotations - This transforms them into the root part direction which is where the angular velocity is transferred.
//vesselPart.rb.angularVelocity = (Quaternion.Inverse(updateVessel.rootPart.rb.rotation) * vesselPart.rb.rotation) * newAng;
vesselPart.rb.angularVelocity = Vector3.zero;
}
}
}
//Flight state controls (Throttle etc)
if (!VesselWorker.fetch.isSpectating)
{
updateVessel.ctrlState.CopyFrom(flightState);
}
else
{
FlightInputHandler.state.CopyFrom(flightState);
}
//Action group controls
updateVessel.ActionGroups.SetGroup(KSPActionGroup.Gear, actiongroupControls[0]);
updateVessel.ActionGroups.SetGroup(KSPActionGroup.Light, actiongroupControls[1]);
updateVessel.ActionGroups.SetGroup(KSPActionGroup.Brakes, actiongroupControls[2]);
updateVessel.ActionGroups.SetGroup(KSPActionGroup.SAS, actiongroupControls[3]);
updateVessel.ActionGroups.SetGroup(KSPActionGroup.RCS, actiongroupControls[4]);
}
示例5: mindistance
public double mindistance(CelestialBody target, double time, double dt, Orbit vesselorbit)
{
double[] dist_at_int = new double[11];
for (int i = 0; i <= 10; i++)
{
double step = time + i * dt;
dist_at_int[i] = (target.getPositionAtUT(step) - vesselorbit.getPositionAtUT(step)).magnitude
;
}
double mindist = dist_at_int.Min();
double maxdist = dist_at_int.Max();
int minindex = Array.IndexOf(dist_at_int, mindist);
if (drawApproachToBody == target) closestApproachTime = time + minindex * dt;
if ((maxdist - mindist) / maxdist >= 0.00001)
mindist = mindistance(target, time + ((minindex - 1) * dt), dt / 5, vesselorbit);
return mindist;
}
示例6: mapPosAtT
private static bool mapPosAtT(Rect maprect, SCANmap map, ref Rect r, Vessel vessel, Orbit o, double dT)
{
double UT = startUT + dT;
if(double.IsNaN(UT)) return false;
try {
if(double.IsNaN(o.getObtAtUT(UT))) return false;
Vector3d pos = o.getPositionAtUT(UT);
double rotation = 0;
if(vessel.mainBody.rotates) {
rotation = (360 * (dT / vessel.mainBody.rotationPeriod)) % 360;
}
double lo = (vessel.mainBody.GetLongitude(pos) - rotation);
double la = (vessel.mainBody.GetLatitude(pos));
double lon = (map.projectLongitude(lo, la) + 180) % 360;
double lat = (map.projectLatitude(lo, la) + 90) % 180;
lat = map.scaleLatitude(lat);
lon = map.scaleLongitude(lon);
if(lat < 0 || lon < 0 || lat > 180 || lon > 360) return false;
lon = lon * maprect.width / 360f;
lat = maprect.height - lat * maprect.height / 180f;
r.x = maprect.x + (float)lon;
r.y = maprect.y + (float)lat;
return true;
} catch(Exception) {
return false;
}
}
示例7: SolveSOI_BSP
public static bool SolveSOI_BSP(Orbit p, Orbit s, ref double UT, double dT, double Rsoi, double MinUT, double MaxUT, double epsilon, int maxIterations, ref int iterationCount)
{
if (UT < MinUT)
{
return false;
}
if (UT > MaxUT)
{
return false;
}
iterationCount = 0;
bool result = false;
double num = Rsoi * Rsoi;
double num2 = Math.Abs((p.getPositionAtUT(UT) - s.getPositionAtUT(UT)).sqrMagnitude - num);
while (dT > epsilon)
{
if (iterationCount < maxIterations)
{
double num3 = (p.getPositionAtUT(UT + dT) - s.getPositionAtUT(UT + dT)).sqrMagnitude - num;
double num4 = (p.getPositionAtUT(UT - dT) - s.getPositionAtUT(UT - dT)).sqrMagnitude - num;
if (UT - dT < MinUT)
{
num4 = 1.7976931348623157E+308;
}
if (UT + dT > MaxUT)
{
num3 = 1.7976931348623157E+308;
}
if (num2 < 0.0)
{
goto IL_146;
}
if (num3 < 0.0)
{
goto IL_146;
}
if (num4 < 0.0)
{
goto IL_146;
}
IL_148:
num3 = Math.Abs(num3);
num4 = Math.Abs(num4);
num2 = Math.Min(num2, Math.Min(num3, num4));
if (num2 == num4)
{
UT -= dT;
}
else if (num2 == num3)
{
UT += dT;
}
dT /= 2.0;
iterationCount++;
Debug.DrawLine(ScaledSpace.LocalToScaledSpace(p.referenceBody.position), ScaledSpace.LocalToScaledSpace(p.getPositionAtUT(UT)), XKCDColors.LightMagenta * 0.5f);
continue;
IL_146:
result = true;
goto IL_148;
}
return result;
}
return result;
}
示例8: SolveClosestApproach
public static double SolveClosestApproach(Orbit p, Orbit s, ref double UT, double dT, double threshold, double MinUT, double MaxUT, double epsilon, int maxIterations, ref int iterationCount)
{
if (UT < MinUT)
{
return -1.0;
}
if (UT > MaxUT)
{
return -1.0;
}
iterationCount = 0;
double num = Math.Abs((p.getPositionAtUT(UT) - s.getPositionAtUT(UT)).sqrMagnitude);
while (dT > epsilon)
{
if (iterationCount >= maxIterations)
{
goto IL_1C2;
}
else
{
double num2 = (p.getPositionAtUT(UT + dT) - s.getPositionAtUT(UT + dT)).sqrMagnitude;
double num3 = (p.getPositionAtUT(UT - dT) - s.getPositionAtUT(UT - dT)).sqrMagnitude;
if (UT - dT < MinUT)
{
num3 = 1.7976931348623157E+308;
}
if (UT + dT > MaxUT)
{
num2 = 1.7976931348623157E+308;
}
num = Math.Min(num, Math.Min(num2, num3));
if (num == num3)
{
UT -= dT;
}
else if (num == num2)
{
UT += dT;
}
dT /= 2.0;
iterationCount++;
Debug.DrawLine(ScaledSpace.LocalToScaledSpace(p.referenceBody.position), ScaledSpace.LocalToScaledSpace(p.getPositionAtUT(UT)), XKCDColors.Lime * 0.5f);
}
}
IL_1C2:
return Math.Sqrt(num);
}
示例9: ApplyVesselUpdate
private void ApplyVesselUpdate(VesselUpdate update)
{
if (HighLogic.LoadedScene == GameScenes.LOADING)
{
return;
}
//Get updating player
string updatePlayer = LockSystem.fetch.LockExists(update.vesselID) ? LockSystem.fetch.LockOwner(update.vesselID) : "Unknown";
//Ignore updates to our own vessel
if (!isSpectating && (FlightGlobals.ActiveVessel != null ? FlightGlobals.ActiveVessel.id.ToString() == update.vesselID : false))
{
DarkLog.Debug("ApplyVesselUpdate - Ignoring update for active vessel from " + updatePlayer);
return;
}
Vessel updateVessel = FlightGlobals.fetch.vessels.FindLast(v => v.id.ToString() == update.vesselID);
if (updateVessel == null)
{
//DarkLog.Debug("ApplyVesselUpdate - Got vessel update for " + update.vesselID + " but vessel does not exist");
return;
}
CelestialBody updateBody = FlightGlobals.Bodies.Find(b => b.bodyName == update.bodyName);
if (updateBody == null)
{
DarkLog.Debug("ApplyVesselUpdate - updateBody not found");
return;
}
if (update.isSurfaceUpdate)
{
double updateDistance = Double.PositiveInfinity;
if ((HighLogic.LoadedScene == GameScenes.FLIGHT) && (FlightGlobals.fetch.activeVessel != null))
{
updateDistance = Vector3.Distance(FlightGlobals.fetch.activeVessel.GetWorldPos3D(), updateVessel.GetWorldPos3D());
}
bool isUnpacking = (updateDistance < updateVessel.distanceUnpackThreshold) && updateVessel.packed;
if (!updateVessel.packed && !isUnpacking)
{
Vector3d updatePostion = updateBody.GetWorldSurfacePosition(update.position[0], update.position[1], update.position[2]);
Vector3d updateVelocity = new Vector3d(update.velocity[0], update.velocity[1], update.velocity[2]);
Vector3d velocityOffset = updateVelocity - updateVessel.srf_velocity;
updateVessel.SetPosition(updatePostion);
updateVessel.ChangeWorldVelocity(velocityOffset);
}
}
else
{
Orbit updateOrbit = new Orbit(update.orbit[0], update.orbit[1], update.orbit[2], update.orbit[3], update.orbit[4], update.orbit[5], update.orbit[6], updateBody);
if (updateVessel.packed)
{
CopyOrbit(updateOrbit, updateVessel.orbitDriver.orbit);
}
else
{
updateVessel.SetPosition(updateOrbit.getPositionAtUT(Planetarium.GetUniversalTime()));
Vector3d velocityOffset = updateOrbit.getOrbitalVelocityAtUT(Planetarium.GetUniversalTime()).xzy - updateVessel.orbit.getOrbitalVelocityAtUT(Planetarium.GetUniversalTime()).xzy;
updateVessel.ChangeWorldVelocity(velocityOffset);
}
}
//Quaternion updateRotation = new Quaternion(update.rotation[0], update.rotation[1], update.rotation[2], update.rotation[3]);
//updateVessel.SetRotation(updateRotation);
Vector3 vesselForward = new Vector3(update.vesselForward[0], update.vesselForward[1], update.vesselForward[2]);
Vector3 vesselUp = new Vector3(update.vesselUp[0], update.vesselUp[1], update.vesselUp[2]);
updateVessel.transform.LookAt(updateVessel.transform.position + updateVessel.mainBody.transform.TransformDirection(vesselForward).normalized, updateVessel.mainBody.transform.TransformDirection(vesselUp));
updateVessel.SetRotation(updateVessel.transform.rotation);
if (!updateVessel.packed)
{
updateVessel.angularVelocity = new Vector3(update.angularVelocity[0], update.angularVelocity[1], update.angularVelocity[2]);
}
if (!isSpectating)
{
updateVessel.ctrlState.CopyFrom(update.flightState);
}
else
{
FlightInputHandler.state.CopyFrom(update.flightState);
}
updateVessel.ActionGroups.SetGroup(KSPActionGroup.Gear, update.actiongroupControls[0]);
updateVessel.ActionGroups.SetGroup(KSPActionGroup.Light, update.actiongroupControls[1]);
updateVessel.ActionGroups.SetGroup(KSPActionGroup.Brakes, update.actiongroupControls[2]);
updateVessel.ActionGroups.SetGroup(KSPActionGroup.SAS, update.actiongroupControls[3]);
updateVessel.ActionGroups.SetGroup(KSPActionGroup.RCS, update.actiongroupControls[4]);
}
示例10: GetPositionAtT
private static bool GetPositionAtT(Vessel thatVessel, Orbit thatOrbit, double initial, double timePoint, out Vector2d coordinates, out bool collision)
{
coordinates = Vector2d.zero;
collision = false;
if (double.IsNaN(thatOrbit.getObtAtUT(initial + timePoint)))
return false;
double rotOffset = 0;
if (thatVessel.mainBody.rotates) {
rotOffset = (360 * ((timePoint - initial) / thatVessel.mainBody.rotationPeriod)) % 360;
}
Vector3d pos = thatOrbit.getPositionAtUT(timePoint);
if (thatOrbit.Radius(timePoint) < thatVessel.mainBody.Radius + thatVessel.mainBody.getElevation(pos)) {
collision = true;
return false;
}
coordinates = new Vector2d(thatVessel.mainBody.GetLongitude(pos) - rotOffset, thatVessel.mainBody.GetLatitude(pos));
return true;
}
示例11: MinTargetDistance
private static double MinTargetDistance(Orbit vesselOrbit, Func<double,Vector3d> targetOrbit, double startTime, double endTime, out double timeAtClosestApproach)
{
var dist_at_int = new double[ClosestApproachRefinementInterval + 1];
double step = startTime;
double dt = (endTime - startTime) / (double)ClosestApproachRefinementInterval;
for (int i = 0; i <= ClosestApproachRefinementInterval; i++) {
dist_at_int[i] = (targetOrbit(step) - vesselOrbit.getPositionAtUT(step)).magnitude;
step += dt;
}
double mindist = dist_at_int.Min();
double maxdist = dist_at_int.Max();
int minindex = Array.IndexOf(dist_at_int, mindist);
if ((maxdist - mindist) / maxdist >= 0.00001) {
// Don't allow negative times. Clamp the startTime to the current startTime.
mindist = MinTargetDistance(vesselOrbit, targetOrbit, startTime + (Math.Max(minindex - 1, 0) * dt), startTime + ((minindex + 1) * dt), out timeAtClosestApproach);
} else {
timeAtClosestApproach = startTime + minindex * dt;
}
return mindist;
}