Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Layout/Force/DragForce.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Layout/Force/DragForce.cs
r2768 r4068 1 1 using System; 2 using System.Collections.Generic;3 using System.Text;4 2 5 namespace Netron.Diagramming.Core.Layout.Force 6 { 3 namespace 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 7 9 /// <summary> 8 /// Implements a viscosity/drag force to help stabilize items.10 /// the parameter names 9 11 /// </summary> 10 public class DragForce : AbstractForce 11 { 12 #region Fields 13 /// <summary> 14 /// the parameter names 15 /// </summary> 16 private static String[] pnames = new String[] { "DragCoefficient" }; 17 /// <summary> 18 /// dragging coefficient 19 /// </summary> 20 public static float DefaultDragCoeff = 0.01f; 21 /// <summary> 22 /// minimum dragging coefficient 23 /// </summary> 24 public static float DefaultMinDragCoeff = 0.0f; 25 /// <summary> 26 /// maximum drag coefficient 27 /// </summary> 28 public static float DefaultMaxDragCoeff = 0.1f; 29 /// <summary> 30 /// current dragging coefficient 31 /// </summary> 32 public static int DragCoeff = 0; 33 #endregion 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 34 30 35 #region Properties 36 /// <summary> 37 /// Returns true. 38 /// </summary> 39 /// <value></value> 40 public override bool IsItemForce 41 { 42 get 43 { 44 return true; 45 } 46 } 47 /// <summary> 48 /// Gets the parameter names. 49 /// </summary> 50 /// <value></value> 51 /// <returns></returns> 52 protected override String[] ParameterNames 53 { 54 get 55 { 56 return pnames; 57 } 58 } 59 #endregion 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 60 52 61 #region Methods 62 /// <summary> 63 /// Create a new DragForce. 64 /// </summary> 65 /// <param name="dragCoeff">The drag coefficient.</param> 66 public DragForce(float dragCoeff) 67 { 68 parms = new float[] { dragCoeff }; 69 minValues = new float[] { DefaultMinDragCoeff }; 70 maxValues = new float[] { DefaultMaxDragCoeff }; 71 } 72 73 /// <summary> 74 /// Create a new DragForce with default drag co-efficient. 75 /// </summary> 76 public DragForce() 77 : this(DefaultDragCoeff) 78 { 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 } 79 63 80 } 81 82 /// <summary> 83 /// Returns the force acting on the given item. 84 /// </summary> 85 /// <param name="item"></param> 86 public override void GetForce(ForceItem item) 87 { 88 item.Force[0] -= parms[DragCoeff] * item.Velocity[0]; 89 item.Force[1] -= parms[DragCoeff] * item.Velocity[1]; 90 } 91 #endregion 92 64 /// <summary> 65 /// Create a new DragForce with default drag co-efficient. 66 /// </summary> 67 public DragForce() 68 : this(DefaultDragCoeff) { 93 69 94 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 } 95 84 }
Note: See TracChangeset
for help on using the changeset viewer.