Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Layout/Force/ForceItem.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/ForceItem.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 /// Represents a point particle in a force simulation, maintaining values for 6 /// mass, forces, velocity, and position. 7 /// </summary> 8 public class ForceItem : ICloneable { 9 #region Fields 7 10 /// <summary> 8 /// Represents a point particle in a force simulation, maintaining values for 9 /// mass, forces, velocity, and position. 11 /// Temporary variables for Runge-Kutta integration 10 12 /// </summary> 11 public class ForceItem : ICloneable 12 { 13 #region Fields 14 /// <summary> 15 /// Temporary variables for Runge-Kutta integration 16 /// </summary> 17 private float[,] l; 18 /// <summary> 19 /// The mass value of this ForceItem. 20 /// </summary> 21 private float mass; 22 /// <summary> The values of the forces acting on this ForceItem. 23 /// </summary> 24 private float[] force; 25 /// <summary> 26 /// The velocity values of this ForceItem. 27 /// </summary> 28 private float[] velocity; 29 /// <summary> 30 /// The location values of this ForceItem. 31 /// </summary> 32 private float[] location; 33 /// <summary> 34 /// The previous location values of this ForceItem. 35 /// /// </summary> 36 private float[] plocation; 37 /// <summary> 38 /// Temporary variables for Runge-Kutta integration 39 /// /// </summary> 40 private float[,] k; 41 #endregion 13 private float[,] l; 14 /// <summary> 15 /// The mass value of this ForceItem. 16 /// </summary> 17 private float mass; 18 /// <summary> The values of the forces acting on this ForceItem. 19 /// </summary> 20 private float[] force; 21 /// <summary> 22 /// The velocity values of this ForceItem. 23 /// </summary> 24 private float[] velocity; 25 /// <summary> 26 /// The location values of this ForceItem. 27 /// </summary> 28 private float[] location; 29 /// <summary> 30 /// The previous location values of this ForceItem. 31 /// /// </summary> 32 private float[] plocation; 33 /// <summary> 34 /// Temporary variables for Runge-Kutta integration 35 /// /// </summary> 36 private float[,] k; 37 #endregion 42 38 43 #region Properties 44 /// <summary> 45 /// Gets or sets the temporary Runge-Kutta integration value. 46 /// </summary> 47 /// <value>The runge kutta temp1.</value> 48 public float[,] RungeKuttaTemp1 49 { 50 get { return k; } 51 set { k = value; } 52 } 39 #region Properties 40 /// <summary> 41 /// Gets or sets the temporary Runge-Kutta integration value. 42 /// </summary> 43 /// <value>The runge kutta temp1.</value> 44 public float[,] RungeKuttaTemp1 { 45 get { return k; } 46 set { k = value; } 47 } 53 48 54 49 55 /// <summary> 56 /// Gets or sets the temporary Runge-Kutta integration value. 57 /// </summary> 58 /// <value>The runge kutta temp2.</value> 59 public float[,] RungeKuttaTemp2 60 { 61 get { return l; } 62 set { l = value; } 63 } 64 /// <summary> 65 /// Gets or sets the mass. 66 /// </summary> 67 /// <value>The mass.</value> 68 public float Mass 69 { 70 get { return mass; } 71 set { mass = value; } 72 } 73 /// <summary> 74 /// Gets or sets the force. 75 /// </summary> 76 /// <value>The force.</value> 77 public float[] Force 78 { 79 get { return force; } 80 set { force = value; } 81 } 82 /// <summary> 83 /// Gets or sets the velocity. 84 /// </summary> 85 /// <value>The velocity.</value> 86 public float[] Velocity 87 { 88 get { return velocity; } 89 set { velocity = value; } 90 } 91 /// <summary> 92 /// Gets or sets the location. 93 /// </summary> 94 /// <value>The location.</value> 95 public float[] Location 96 { 97 get { return location; } 98 set { location = value; } 99 } 100 /// <summary> 101 /// Gets or sets the previous location. 102 /// </summary> 103 /// <value>The previous location.</value> 104 public float[] PreviousLocation 105 { 106 get { return plocation; } 107 set { plocation = value; } 108 } 50 /// <summary> 51 /// Gets or sets the temporary Runge-Kutta integration value. 52 /// </summary> 53 /// <value>The runge kutta temp2.</value> 54 public float[,] RungeKuttaTemp2 { 55 get { return l; } 56 set { l = value; } 57 } 58 /// <summary> 59 /// Gets or sets the mass. 60 /// </summary> 61 /// <value>The mass.</value> 62 public float Mass { 63 get { return mass; } 64 set { mass = value; } 65 } 66 /// <summary> 67 /// Gets or sets the force. 68 /// </summary> 69 /// <value>The force.</value> 70 public float[] Force { 71 get { return force; } 72 set { force = value; } 73 } 74 /// <summary> 75 /// Gets or sets the velocity. 76 /// </summary> 77 /// <value>The velocity.</value> 78 public float[] Velocity { 79 get { return velocity; } 80 set { velocity = value; } 81 } 82 /// <summary> 83 /// Gets or sets the location. 84 /// </summary> 85 /// <value>The location.</value> 86 public float[] Location { 87 get { return location; } 88 set { location = value; } 89 } 90 /// <summary> 91 /// Gets or sets the previous location. 92 /// </summary> 93 /// <value>The previous location.</value> 94 public float[] PreviousLocation { 95 get { return plocation; } 96 set { plocation = value; } 97 } 109 98 110 99 111 100 #endregion 112 101 113 #region Constructor 114 /// <summary> 115 /// Create a new ForceItem. 116 /// </summary> 117 public ForceItem() 118 { 119 mass = 1.0f; 120 force = new float[] { 0.0F, 0.0F }; 121 velocity = new float[] { 0.0F, 0.0F }; 122 location = new float[] { 0.0F, 0.0F }; 123 plocation = new float[] { 0.0F, 0.0F }; 124 k = new float[4, 2]; 125 l = new float[4, 2]; 126 } 102 #region Constructor 103 /// <summary> 104 /// Create a new ForceItem. 105 /// </summary> 106 public ForceItem() { 107 mass = 1.0f; 108 force = new float[] { 0.0F, 0.0F }; 109 velocity = new float[] { 0.0F, 0.0F }; 110 location = new float[] { 0.0F, 0.0F }; 111 plocation = new float[] { 0.0F, 0.0F }; 112 k = new float[4, 2]; 113 l = new float[4, 2]; 114 } 127 115 128 116 #endregion 129 117 130 118 131 119 132 #region Methods 133 /// <summary> 134 /// Checks a ForceItem to make sure its values are all valid numbers(i.e., not NaNs). 135 /// </summary> 136 /// <param name="item">The item to check.</param> 137 /// <returns> 138 /// <c>true</c> if the specified item is valid; otherwise, <c>false</c>. 139 /// </returns> 140 public static bool isValid(ForceItem item) 141 { 142 return 143 !(float.IsNaN(item.location[0]) || float.IsNaN(item.location[1]) || 144 float.IsNaN(item.plocation[0]) || float.IsNaN(item.plocation[1]) || 145 float.IsNaN(item.velocity[0]) || float.IsNaN(item.velocity[1]) || 146 float.IsNaN(item.force[0]) || float.IsNaN(item.force[1])); 147 } 120 #region Methods 121 /// <summary> 122 /// Checks a ForceItem to make sure its values are all valid numbers(i.e., not NaNs). 123 /// </summary> 124 /// <param name="item">The item to check.</param> 125 /// <returns> 126 /// <c>true</c> if the specified item is valid; otherwise, <c>false</c>. 127 /// </returns> 128 public static bool isValid(ForceItem item) { 129 return 130 !(float.IsNaN(item.location[0]) || float.IsNaN(item.location[1]) || 131 float.IsNaN(item.plocation[0]) || float.IsNaN(item.plocation[1]) || 132 float.IsNaN(item.velocity[0]) || float.IsNaN(item.velocity[1]) || 133 float.IsNaN(item.force[0]) || float.IsNaN(item.force[1])); 134 } 148 135 149 136 150 /// <summary> 151 /// Creates a new object that is a copy of the current instance. 152 /// </summary> 153 /// <returns> 154 /// A new object that is a copy of this instance. 155 /// </returns> 156 public object Clone() 157 { 158 //ForceItem item = new ForceItem(); 159 //item.mass = this.mass; 160 //Array.Copy(force, 0, item.force, 0, 2); 161 //Array.Copy(velocity, 0, item.velocity, 0, 2); 162 //Array.Copy(location, 0, item.location, 0, 2); 163 //Array.Copy(plocation, 0, item.plocation, 0, 2); 164 //for (int i = 0; i < k.Length; ++i) 165 //{ 166 // Array.Copy(k[i,], 0, item.k[i,], 0, 2); 167 // Array.Copy(l[i], 0, item.l[i], 0, 2); 168 // Array 169 //} 170 //return item; 171 throw new NotImplementedException("Do you really need this feature?"); 172 } 173 #endregion 137 /// <summary> 138 /// Creates a new object that is a copy of the current instance. 139 /// </summary> 140 /// <returns> 141 /// A new object that is a copy of this instance. 142 /// </returns> 143 public object Clone() { 144 //ForceItem item = new ForceItem(); 145 //item.mass = this.mass; 146 //Array.Copy(force, 0, item.force, 0, 2); 147 //Array.Copy(velocity, 0, item.velocity, 0, 2); 148 //Array.Copy(location, 0, item.location, 0, 2); 149 //Array.Copy(plocation, 0, item.plocation, 0, 2); 150 //for (int i = 0; i < k.Length; ++i) 151 //{ 152 // Array.Copy(k[i,], 0, item.k[i,], 0, 2); 153 // Array.Copy(l[i], 0, item.l[i], 0, 2); 154 // Array 155 //} 156 //return item; 157 throw new NotImplementedException("Do you really need this feature?"); 174 158 } 159 #endregion 160 } 175 161 }
Note: See TracChangeset
for help on using the changeset viewer.