当前位置: 首页>>代码示例>>C#>>正文


C# TimeStep类代码示例

本文整理汇总了C#中TimeStep的典型用法代码示例。如果您正苦于以下问题:C# TimeStep类的具体用法?C# TimeStep怎么用?C# TimeStep使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TimeStep类属于命名空间,在下文中一共展示了TimeStep类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的TimeStep类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。