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/ForceItem.cs @ 3175

Last change on this file since 3175 was 2768, checked in by mkommend, 14 years ago

added solution folders and sources for the netron library (ticket #867)

File size: 5.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Netron.Diagramming.Core.Layout.Force
6{
7    /// <summary>
8    /// Represents a point particle in a force simulation, maintaining values for
9    /// mass, forces, velocity, and position.
10    /// </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
42
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        }
53
54
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        }
109
110
111        #endregion
112
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        }
127
128        #endregion
129
130
131
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        }
148
149
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
174    }
175}
Note: See TracBrowser for help on using the repository browser.