Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Layout/Force/DragForce.cs @ 4068

Last change on this file since 4068 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 2.2 KB
Line 
1using System;
2
3namespace Netron.Diagramming.Core.Layout.Force {
4  /// <summary>
5  ///  Implements a viscosity/drag force to help stabilize items.
6  /// </summary>
7  public class DragForce : AbstractForce {
8    #region Fields
9    /// <summary>
10    /// the parameter names
11    /// </summary>
12    private static String[] pnames = new String[] { "DragCoefficient" };
13    /// <summary>
14    /// dragging coefficient
15    /// </summary>
16    public static float DefaultDragCoeff = 0.01f;
17    /// <summary>
18    /// minimum dragging coefficient
19    /// </summary>
20    public static float DefaultMinDragCoeff = 0.0f;
21    /// <summary>
22    /// maximum drag coefficient
23    /// </summary>
24    public static float DefaultMaxDragCoeff = 0.1f;
25    /// <summary>
26    /// current dragging coefficient
27    /// </summary>
28    public static int DragCoeff = 0;
29    #endregion
30
31    #region Properties
32    /// <summary>
33    /// Returns true.
34    /// </summary>
35    /// <value></value>
36    public override bool IsItemForce {
37      get {
38        return true;
39      }
40    }
41    /// <summary>
42    /// Gets the parameter names.
43    /// </summary>
44    /// <value></value>
45    /// <returns></returns>
46    protected override String[] ParameterNames {
47      get {
48        return pnames;
49      }
50    }
51    #endregion
52
53    #region Methods
54    /// <summary>
55    ///  Create a new DragForce.
56    /// </summary>
57    /// <param name="dragCoeff">The drag coefficient.</param>
58    public DragForce(float dragCoeff) {
59      parms = new float[] { dragCoeff };
60      minValues = new float[] { DefaultMinDragCoeff };
61      maxValues = new float[] { DefaultMaxDragCoeff };
62    }
63
64    /// <summary>
65    /// Create a new DragForce with default drag co-efficient.
66    /// </summary>
67    public DragForce()
68      : this(DefaultDragCoeff) {
69
70    }
71
72    /// <summary>
73    /// Returns the force acting on the given item.
74    /// </summary>
75    /// <param name="item"></param>
76    public override void GetForce(ForceItem item) {
77      item.Force[0] -= parms[DragCoeff] * item.Velocity[0];
78      item.Force[1] -= parms[DragCoeff] * item.Velocity[1];
79    }
80    #endregion
81
82
83  }
84}
Note: See TracBrowser for help on using the repository browser.