本文整理汇总了C#中TimeStep类的典型用法代码示例。如果您正苦于以下问题:C# TimeStep类的具体用法?C# TimeStep怎么用?C# TimeStep使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeStep类属于命名空间,在下文中一共展示了TimeStep类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TimeValueList
/// <summary>
/// Creates a new regular-spaced list and sets all values to initialValue
/// </summary>
/// <param name="period"></param>
/// <param name="step"></param>
/// <param name="initialValue"></param>
/// <returns></returns>
public TimeValueList(TimeInterval period, TimeStep step, double initialValue)
{
_timeStepFactor = (step == TimeStep.Hour) ? 24 : 1;
_start = period.Start.ToOADate();
switch(TimeStep)
{
case TimeStep.Hour:
_data = new double[(int) period.Length.TotalHours];
break;
case TimeStep.Day:
_data = new double[(int) period.Length.TotalDays];
break;
default:
throw new ArgumentException("'step' parameter must be 'Hour' or 'Day'");
}
if (initialValue != 0.0)
{
// initialize array values...
for (int i = 0; i < _data.Length; ++i)
{
_data[i] = initialValue;
}
}
}
开发者ID:jirikadlec2,项目名称:hydrodata,代码行数:33,代码来源:TimeValueList.cs
示例2: GetMissingValuesHydro
public static HydroTimeSeries GetMissingValuesHydro(ITimeSeries ts, DateTime start, DateTime end, TimeStep step)
{
HydroTimeSeries missingTs = new HydroTimeSeries(start, end);
List<int> breakIx = GetDataBreaks(ts);
//TODO missing points before series start
foreach (int begIndex in breakIx)
{
if (begIndex < ts.Count - 1)
{
DateTime begDate = DateTime.FromOADate(ts[begIndex].X);
DateTime endDate = DateTime.FromOADate(ts[begIndex + 1].X);
if (step == TimeStep.Day)
{
int nd = (int)endDate.Subtract(begDate).TotalDays;
for (int i = 0; i < nd; i++)
{
DateTime newTime = begDate.AddDays(i);
missingTs.AddUnknownValue(newTime);
}
}
else
{
int nh = (int)endDate.Subtract(begDate).TotalHours;
for (int i = 0; i < nh; i++)
{
DateTime newTime = begDate.AddHours(i);
missingTs.AddUnknownValue(newTime);
}
}
}
}
return missingTs;
}
开发者ID:jirikadlec2,项目名称:hydrodata,代码行数:34,代码来源:TimeSeriesManager.cs
示例3: FillDataGaps
/// <summary>
/// Fills the data gaps inside the time-series by setting them to 'no data' vals
/// </summary>
/// <param name="ts"></param>
public static ITimeSeries FillDataGaps(ITimeSeries ts, TimeStep step)
{
ITimeSeries myTs = MakeRegularTimeSeries(ts.Start, ts.End, step);
if (step == TimeStep.Day)
{
double tStart = myTs[0].X;
for (int i = 0; i < ts.Count - 1; i++)
{
double index = (ts[i].X - tStart);
int ix = (int)index;
myTs[ix].Y = ts[i].Y;
}
}
else
{
double tStart = myTs[0].X * 24;
for (int i = 0; i < ts.Count - 1; i++)
{
double index = (ts[i].X * 24 - tStart);
int ix = (int)index;
myTs[ix].Y = ts[i].Y;
}
}
return myTs;
}
开发者ID:jirikadlec2,项目名称:hydrodata,代码行数:29,代码来源:TimeSeriesManager.cs
示例4: ServiceRate
public ServiceRate(string serviceName,TimeStep timeStep,DateTime stamp,int rate)
{
this.ServiceName = serviceName;
this.RateTimeStep = timeStep;
this.TimeStamp = stamp;
this.Rate = rate;
}
开发者ID:ryansecret,项目名称:MonitroCenter,代码行数:7,代码来源:ServiceRate.cs
示例5: Step
public override void Step(TimeStep step)
{
if (_bodyList == null) return;
if (useWorldGravity)
{
gravity = _world.Gravity;
}
for (ControllerEdge i = _bodyList; i != null; i = i.nextBody)
{
Body body = i.body;
if (body.IsSleeping())
{
//Buoyancy force is just a function of position,
//so unlike most forces, it is safe to ignore sleeping bodes
continue;
}
Vec2 areac = new Vec2(0, 0);
Vec2 massc = new Vec2(0, 0);
float area = 0;
float mass = 0;
for (Shape shape = body.GetShapeList(); shape != null; shape = shape.GetNext())
{
Vec2 sc;
float sarea = shape.ComputeSubmergedArea(normal, offset, body.GetXForm(), out sc);
area += sarea;
areac.X += sarea * sc.X;
areac.Y += sarea * sc.Y;
float shapeDensity = 0;
if (useDensity)
{
//TODO: Expose density publicly
shapeDensity = shape.Density;
}
else
{
shapeDensity = 1;
}
mass += sarea * shapeDensity;
massc.X += sarea * sc.X * shapeDensity;
massc.Y += sarea * sc.Y * shapeDensity;
}
areac.X /= area;
areac.Y /= area;
massc.X /= mass;
massc.Y /= mass;
if (area < Box2DX.Common.Settings.FLT_EPSILON)
continue;
//Buoyancy
Vec2 buoyancyForce = -density * area * gravity;
body.ApplyForce(buoyancyForce, massc);
//Linear drag
Vec2 dragForce = body.GetLinearVelocityFromWorldPoint(areac) - velocity;
dragForce *= -linearDrag * area;
body.ApplyForce(dragForce, areac);
//Angular drag
//TODO: Something that makes more physical sense?
body.ApplyTorque(-body.GetInertia() / body.GetMass() * area * body.GetAngularVelocity() * angularDrag);
}
}
开发者ID:danielpcox,项目名称:Crisis-at-Swiss-Station,代码行数:59,代码来源:BuoyancyController.cs
示例6: InitVelocityConstraints
internal override void InitVelocityConstraints(ref TimeStep step)
{
_jointError = BodyA.Sweep.A - TargetAngle;
_bias = -BiasFactor * step.inv_dt * _jointError;
_massFactor = (1 - Softness) / (BodyA.InvI);
}
开发者ID:pbhogan,项目名称:FarseerUnity,代码行数:8,代码来源:FixedAngleJoint.cs
示例7: Step
public override void Step(TimeStep step)
{
for (ControllerEdge i = _bodyList; i != null; i = i.nextBody)
{
Body body = i.body;
if (body.IsSleeping())
continue;
body.SetLinearVelocity(body.GetLinearVelocity() + step.Dt * A);
}
}
开发者ID:KrugerHeavyIndustries,项目名称:box2d-unity,代码行数:10,代码来源:ConstantAccelController.cs
示例8: Step
public override void Step(TimeStep step)
{
//B2_NOT_USED(step);
for (ControllerEdge i = _bodyList; i != null; i = i.nextBody)
{
Body body = i.body;
if (body.IsSleeping())
continue;
body.ApplyForce(F, body.GetWorldCenter());
}
}
开发者ID:ajmaya,项目名称:box2dx,代码行数:11,代码来源:ConstantForceController.cs
示例9: ReadBinaryFile
public static void ReadBinaryFile(string fileName, DateTime startTime, DateTime endTime, TimeStep timeStep,
bool includeNA, IObservationList observations)
{
if (timeStep == TimeStep.Day)
{
ReadBinaryFileDaily(fileName, startTime, endTime, includeNA, observations);
}
else
{
ReadBinaryFileHourly(fileName, startTime, endTime, includeNA, observations);
}
}
开发者ID:jirikadlec2,项目名称:hydrodata,代码行数:12,代码来源:BinaryFileHelper.cs
示例10: RunLogic
protected internal override void RunLogic(TimeStep step)
{
foreach (Body e in this.Bodies)
{
if (e.IgnoresGravity ||
e.IgnoresPhysicsLogics)
{
continue;
}
Vector2D.Add(ref e.State.Acceleration.Linear, ref gravity, out e.State.Acceleration.Linear);
}
}
开发者ID:timdetering,项目名称:Physics2D.Net,代码行数:13,代码来源:GravityField.cs
示例11: Detect
public override void Detect(TimeStep step)
{
for (int index1 = 0; index1 < this.Bodies.Count; index1++)
{
Body body1 = this.Bodies[index1];
for (int index2 = index1 + 1; index2 < this.Bodies.Count; index2++)
{
Body body2 = this.Bodies[index2];
if ((body1.Mass.MassInv != 0 || body2.Mass.MassInv != 0) &&
Body.CanCollide(body1, body2) &&
body1.Rectangle.Intersects(body2.Rectangle))
{
OnCollision(step, body1, body2);
}
}
}
}
开发者ID:timdetering,项目名称:Physics2D.Net,代码行数:17,代码来源:BruteForceDetector.cs
示例12: RunLogic
protected internal override void RunLogic(TimeStep step)
{
foreach (Body e in this.Bodies)
{
if (e.IgnoresGravity ||
e.IgnoresPhysicsLogics)
{
continue;
}
Vector2D vect;
Vector2D.Subtract(ref location, ref e.State.Position.Linear, out vect);
Vector2D.Normalize(ref vect, out vect);
Vector2D.Multiply(ref vect, ref gravity, out vect);
Vector2D.Add(ref e.State.Acceleration.Linear, ref vect, out e.State.Acceleration.Linear);
}
}
开发者ID:bsvercl,项目名称:physics2d,代码行数:17,代码来源:GravityPointField.cs
示例13: Step
public override void Step(TimeStep step)
{
float timestep = step.Dt;
if (timestep <= Settings.FLT_EPSILON)
return;
if (timestep > MaxTimestep && MaxTimestep > 0)
timestep = MaxTimestep;
for (ControllerEdge i = _bodyList; i != null; i = i.nextBody)
{
Body body = i.body;
if (body.IsSleeping())
continue;
Vec2 damping = body.GetWorldVector(Math.Mul(T, body.GetLocalVector(body.GetLinearVelocity())));
body.SetLinearVelocity(body.GetLinearVelocity() + timestep*damping);
}
}
开发者ID:ajmaya,项目名称:box2dx,代码行数:17,代码来源:TensorDampingController.cs
示例14: RunLogic
protected internal override void RunLogic(TimeStep step)
{
foreach (Body e in Bodies)
{
if (e == body ||
e.IgnoresGravity ||
e.IgnoresPhysicsLogics)
{
continue;
}
Scalar magnitude;
Vector2D gravity;
Vector2D.Subtract(ref body.State.Position.Linear, ref e.State.Position.Linear, out gravity);
Vector2D.Normalize(ref gravity, out magnitude, out gravity);
magnitude = (body.Mass.AccelerationDueToGravity /
(magnitude * magnitude * metersPerDistanceUnit * metersPerDistanceUnit));
Vector2D.Multiply(ref gravity, ref magnitude, out gravity);
Vector2D.Add(ref e.State.Acceleration.Linear, ref gravity, out e.State.Acceleration.Linear);
}
}
开发者ID:bsvercl,项目名称:physics2d,代码行数:20,代码来源:GravityPointMass.cs
示例15: LoadObservationsDischarge
/// <summary>
/// Retrieves a time series of discharge observations from the database
/// (only measured, non-zero values are retrieved)
/// </summary>
/// <param name="stationId"></param>
/// <param name="variableId"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="scaleFactor"></param>
/// <param name="observations"></param>
public static void LoadObservationsDischarge(int stationId, int variableId, DateTime start, DateTime end,
TimeStep step, IObservationList observations)
{
//observations.Clear();
SqlCommand cmd = DataUtils.CreateCommand();
cmd.CommandText = "plaveninycz.new_query_observations";
cmd.CommandType = CommandType.StoredProcedure;
SetCmdParameters(cmd, stationId, variableId, start, end, step);
SqlDataReader rdr;
double val;
DateTime t;
try
{
cmd.Connection.Open();
rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (rdr.Read())
{
if (!rdr.IsDBNull(1))
{
t = Convert.ToDateTime(rdr[0]);
val = Convert.ToDouble(rdr[1]);
//val = Math.Pow(2.0, (val / 1000.0));
if (val > 0)
{
observations.AddObservation(t, val);
}
else
{
observations.AddUnknownValue(t);
}
}
}
rdr.Close();
}
finally
{
cmd.Connection.Close();
}
}
开发者ID:jirikadlec2,项目名称:hydrodata,代码行数:51,代码来源:TimeSeriesDS.cs
示例16: Step
public override void Step(TimeStep step)
{
//B2_NOT_USED(step);
if (InvSqr)
{
for (ControllerEdge i = _bodyList; i != null; i = i.nextBody)
{
Body body1 = i.body;
for (ControllerEdge j = _bodyList; j != i; j = j.nextBody)
{
Body body2 = j.body;
Vector2 d = body2.GetWorldCenter() - body1.GetWorldCenter();
float r2 = d.sqrMagnitude;
if (r2 < Settings.FLT_EPSILON)
continue;
Vector2 f = G / r2 / Math.Sqrt(r2) * body1.GetMass() * body2.GetMass() * d;
body1.ApplyForce(f, body1.GetWorldCenter());
body2.ApplyForce(-1.0f * f, body2.GetWorldCenter());
}
}
}
else
{
for (ControllerEdge i = _bodyList; i != null; i = i.nextBody)
{
Body body1 = i.body;
for (ControllerEdge j = _bodyList; j != i; j = j.nextBody)
{
Body body2 = j.body;
Vector2 d = body2.GetWorldCenter() - body1.GetWorldCenter();
float r2 = d.sqrMagnitude;
if (r2 < Settings.FLT_EPSILON)
continue;
Vector2 f = G / r2 * body1.GetMass() * body2.GetMass() * d;
body1.ApplyForce(f, body1.GetWorldCenter());
body2.ApplyForce(-1.0f * f, body2.GetWorldCenter());
}
}
}
}
开发者ID:KrugerHeavyIndustries,项目名称:box2d-unity,代码行数:41,代码来源:GravityController.cs
示例17: RunLogic
protected internal override void RunLogic(TimeStep step)
{
foreach (Body e in Bodies)
{
if (e.IgnoresPhysicsLogics) { continue; }
Scalar velocity;
Vector2D.GetMagnitude(ref e.State.Velocity.Linear, out velocity);
if (velocity > maxLinearVelocity)
{
velocity = maxLinearVelocity / velocity;
Vector2D.Multiply(ref e.State.Velocity.Linear, ref velocity, out e.State.Velocity.Linear);
}
if (e.State.Velocity.Angular > maxAngularVelocity)
{
e.State.Velocity.Angular = maxAngularVelocity;
}
else if (e.State.Velocity.Angular < -maxAngularVelocity)
{
e.State.Velocity.Angular = -maxAngularVelocity;
}
}
}
开发者ID:bsvercl,项目名称:physics2d,代码行数:22,代码来源:VelocityLimitLogic.cs
示例18: InitVelocityConstraints
internal override void InitVelocityConstraints(ref TimeStep step)
{
Body b1 = BodyA;
Body b2 = BodyB;
Transform xf1, xf2;
b1.GetTransform(out xf1);
b2.GetTransform(out xf2);
Vector2 r1 = MathUtils.Multiply(ref xf1.R, LocalAnchorA - b1.LocalCenter);
Vector2 r2 = MathUtils.Multiply(ref xf2.R, LocalAnchorB - b2.LocalCenter);
Vector2 p1 = b1.Sweep.c + r1;
Vector2 p2 = b2.Sweep.c + r2;
Vector2 s1 = GroundAnchorA;
Vector2 s2 = GroundAnchorB;
// Get the pulley axes.
_u1 = p1 - s1;
_u2 = p2 - s2;
float length1 = _u1.Length();
float length2 = _u2.Length();
if (length1 > Settings.LinearSlop)
{
_u1 *= 1.0f / length1;
}
else
{
_u1 = Vector2.Zero;
}
if (length2 > Settings.LinearSlop)
{
_u2 *= 1.0f / length2;
}
else
{
_u2 = Vector2.Zero;
}
float C = _ant - length1 - Ratio * length2;
if (C > 0.0f)
{
_state = LimitState.Inactive;
_impulse = 0.0f;
}
else
{
_state = LimitState.AtUpper;
}
if (length1 < _maxLengthA)
{
_limitState1 = LimitState.Inactive;
_limitImpulse1 = 0.0f;
}
else
{
_limitState1 = LimitState.AtUpper;
}
if (length2 < _maxLengthB)
{
_limitState2 = LimitState.Inactive;
_limitImpulse2 = 0.0f;
}
else
{
_limitState2 = LimitState.AtUpper;
}
// Compute effective mass.
float cr1u1 = MathUtils.Cross(r1, _u1);
float cr2u2 = MathUtils.Cross(r2, _u2);
_limitMass1 = b1.InvMass + b1.InvI * cr1u1 * cr1u1;
_limitMass2 = b2.InvMass + b2.InvI * cr2u2 * cr2u2;
_pulleyMass = _limitMass1 + Ratio * Ratio * _limitMass2;
Debug.Assert(_limitMass1 > Settings.Epsilon);
Debug.Assert(_limitMass2 > Settings.Epsilon);
Debug.Assert(_pulleyMass > Settings.Epsilon);
_limitMass1 = 1.0f / _limitMass1;
_limitMass2 = 1.0f / _limitMass2;
_pulleyMass = 1.0f / _pulleyMass;
if (Settings.EnableWarmstarting)
{
// Scale impulses to support variable time steps.
_impulse *= step.dtRatio;
_limitImpulse1 *= step.dtRatio;
_limitImpulse2 *= step.dtRatio;
// Warm starting.
Vector2 P1 = -(_impulse + _limitImpulse1) * _u1;
Vector2 P2 = (-Ratio * _impulse - _limitImpulse2) * _u2;
b1.LinearVelocityInternal += b1.InvMass * P1;
b1.AngularVelocityInternal += b1.InvI * MathUtils.Cross(r1, P1);
//.........这里部分代码省略.........
开发者ID:scastle,项目名称:Solitude,代码行数:101,代码来源:PullyJoint.cs
示例19: UpdateTime
protected internal virtual void UpdateTime(TimeStep step)
{
this.lifetime.Update(step);
}
开发者ID:timdetering,项目名称:Physics2D.Net,代码行数:4,代码来源:PhysicsLogic.cs
示例20: RunLogic
protected internal abstract void RunLogic(TimeStep step);
开发者ID:timdetering,项目名称:Physics2D.Net,代码行数:1,代码来源:PhysicsLogic.cs
注:本文中的TimeStep类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论