Hello Vandana Matai,
I'm not sure whether the implementation is built that way on purpose or whether it is an error, so I'm not sure whether I can help you. Let me address your questions:
1. In project, I have used trace "posX= ",posX, "Value of posX= ",Path1.GetNodeX( 0,noOfEdge); at many places. I don't understand why these values are different.
So far I don't see any error in the logged numbers. Let us analyze the code section at the end of the method onUpdatePath:
else if (noOfEdge <= 1001)
{
Path1.AddLine(0,posX/8,newValue);
trace "posX= ",posX,"posX/4= ",posX/8,"Value of posX= ",Path1.GetNodeX( 0,noOfEdge);
}
... and the corresponding logged values:
(1) trace: "posX= ", 4495.5, "posX/4= ", 561.9375, "Value of posX= ", 280.6875.
(2) trace: "posX= ", 4500.0, "posX/4= ", 562.5, "Value of posX= ", 280.96875.
(3) trace: "posX= ", 4504.5, "posX/4= ", 563.0625, "Value of posX= ", 280.96875.
...
(N) trace: "posX= ", 4581.0, "posX/4= ", 572.625, "Value of posX= ", 280.96875.
The logged value posX ist o.k. With each step it increments by 4.5. The trace value posX/4 is incorrectly logged. In fact the implementation calculates with posX/8. Nevertheless with 1/8 my calculator produces the same results accordingly. The last traced value GetNodeX( 0, noOfEdges ) is confusing a little bit. GetNodeX() queries the value stored at position noOfEdges. This corresponds to last position in the path. However, in your implementation you perform shortly before an AddLine() operation. The value provided in AddLine() is thus stored at position noOfEdges+1. Querying the value at noOfEdges returns thus the value from the preceding iteration. This explains why "Value of posX" does correspond to the calculation from the line above.
Also important is that values returned by GetNodeX() are half of what you stored there in advance. This is correct, since at step 81 you have configured the path to scale the X coordinates by 0.5. This configuration remains active and affects the coordinates passed in all subsequent AddLine() and other AddXXX() invocations.
Interesting is that once posX assumed the value 4500, there is no change in "Value of posX". It is always 280.96875. The explanation is clear, the path is configured with capacity of 1000 edges. With the value 4500 you have added 1000 edges to the path (1000 * 4.5 = 4500). From this moment the AddLine() operation have no effect anymore.
2. 80th value ends at 180 and 81th starts at 180 at X axis. 81 value which is logically half (182.25) of what usually would have been (without scaling- 364.5). This is well understood and perfect up to 160 values. After that I have to use posX/2 or posX/4 or posX/8 to restart the plotting at the last saved X position. Why is that so?
I think this is because with step 81 the path has been configured to scale all values by factor 0.5. This configuration is still active and affects all AddLine() operations.
3. Is there any way to make a plot in which, I plot upto 360 values first and then with every next value, graph re-scales to add that new value.
The simplest would be to:
Step 1: use two path objects path1 and path2.
Step 2: The Stroke Path view is connected primarily to the path1.
Step 3: All new data is stored always in path1. For the moment the changes in path1 are displayed in Stroke Path view.
Step 4: When new data is stored in path1 track the number of the already stored entries or the value range of the entries.
Step 5: When the number of entries (or the value range) exceeds a predetermined threshold, assign path2 to the Stroke Path view.
From now (when the number entries is too large) following steps are to be done:
Step 6: With each new data calculate the desired scaling factors from either the number of entries in path1 or the range of the values you tracked.
Step 7: With each new data initialize path2 using InitSubPath() so path2 is empty.
Step 8: Use the calculated scaling factors (from step 6) to Scale() subsequent operations on path2.
Step 9: Then copy path1 content to path2 using the method path2.AddCopy().
Step 10: Reset the scaling of path2 by using the method InitMatrix(). See also Apply 2D transformations during the path creation.
Please note also that floating point values have limited precision. Especially, the larger a value, the less precise it is represented by floating point. This 'in-precision' may accumulate (grow) with each calculation step. This is the nature of floating points. With posX growing the calculation with this value may become less precise. It is thus recommended to not let posX increment endlessly.
I hope it helps you further.
Best regards
Paul Banach