|
3D Graphs Class methods expansions |
Posted by Sal on Sep-26-2015 00:12 |
|
Hi Peter,
Using your hints in response to previous my requests, and others available in your Forum, I was able to produce a complex 3D chants (Drawing) that contains many series of irregular area data points enclosed by lines, where each area has different color. Imagine some sort of 3D solid Object.
Originally I was planning to use exclusively ThreeDScatterChart, but this does not allow to connect points with line and to color each area directly as I wanted for several good reasons (Look like few people asked about this in the past...)
So, I had to fall back in using the ThreeDChart.getXCoor() + ThreeDChart.getYCoor() methods to get each pixel (X,Y) point I want to plot and use some drawing methods I created via your DrawArea class to perform the drawing
This Class (DrawArea) is great to use to add few lines or boxes over the 3D chart (something the 3D Class produced directly - what is designed for)
The process above I described is quite cumbersome to produce the type of CAD drawing I am now able to produce from a Library intended to plot results of scientific chart or similar, only.
The point I am trying to make is that it is possible to use your Library for something more, not always intuitive at first hand
Of course I had to overcome some logical issue, like the drawing Z order of each logical series of points I wanted to represent and I had to write logic to hide certain area as needed, all these reasons are the ones that prevent to use the ThreeDScatterChart directly for this type of drawing you mentioned in the past
I made it working by keeping track of several issues as you might imagine (i.e.: Rotation angle, Elevation, order of the layers along the X axis, etc...)
Q1: Is it possible to request the expansion of the ThreeDChart class methods to produce multiple X,Y pixel points at once ? I was envisioning to pass an array of 3D points, the number of points and have back via a new method into 2 supplied arrays the X and Y pixel points pair. Basically this method would call directly the internal code that is executed in response to each getXCoor() and getYCoor() calls multiple times
Q2: What about adding a new method getXYCoor() that returns the pair X,Y Pixels at once, instead of using 2 calls to getXCoor() and getYCoor() ? This would help some.
My Q1 + Q2 suggested improvements would improve the performance of the Library when used for what I described, though it was not designed directly for what I am using it and will be used by someone like me it is trying to do more than others
Q3: What about to add a class similar what ThreeDScatterChart to address the many requests that allows to plots the regions I had to produce the hard way.
Of course this new class would produce 1 Enclosed Area only. The user would be responsible to manipulate each added layer to produce his intended objective
Peter, I understand I might be asking a lot with Q3, but I am happy with V6 of the library as it is, though I am using it for more it was indented for.
If nothing else, Q1 and Q2 are not too tough and I believe they should be considered and included in future releases of the library, since the would increase its performance and usability
I hope you consider my proposal as product improvements and that would allow your product to be used for so much more it was originally designed for
Thanks for the attention
Sincerely
Sal |
Re: 3D Graphs Class methods expansions |
Posted by Sal on Sep-26-2015 02:02 |
|
Peter,
I attached 2 examples that show of how far ChartDirector V6 Library can be pushed to.
As you can imagine, since I Rotate and Manage the Operation my self, there are a lot of getXCoor() and getYCoor() calls to execute and this slows down the drawing operation (Most notice if I Turn the Image + Redraw it in response to mouse actions)
I am in the work to speed up the operation of my code.
Methods Expansion mentioned in Q1 and Q2 would help quite a bit
Q3 method if ever available, would remove the issue all together
Till anything I asked happens...
Q4: Would I be gaining anything by having 2 Threads instead of the running thread do all the work to calls to the above 2 functions (split the working load of calculating the Pixel coordinates at the new Rotated Position) ?
Not sure of the answer to the question above, since I am not clear by reading the Library Documentation of the Pros and Cons I would obtain from the above method, without trying
The documentation has no references of what happen when the same object is accessed from 2 threads for write/read operation.
Thanks
Sal
|
Re: 3D Graphs Class methods expansions |
Posted by Peter Kwan on Sep-29-2015 03:45 |
|
Hi Sal,
For drawing an arbitrary 3D shape, it is much more complicated in the general case,
especially with transparency and all the coloring and lighting features (such as changing
color based on the z-level) supported by ChartDirector. It is also normally not possible to
determine the z-order of the surfaces (except under very limited cases), as the surfaces
often mutually overlap. (In fact, in your chart, it looks like the pink and blue surfaces should
mutually overlap as they seem to intersect, with part of the blue surface going under the
pink surface). Normally, some sort of hardware acceleration based on OpenGL or DirectX is
required.
For using an array for getXCoor and getYCoor, we will examine this in more details. We
known it requires certain computations to calculate the x and y coordinates, and then more
overhead later to use those coordinates to draw the polygon. If the getXCoor/getYCoor can
accept an array, your code do not need to call these methods so many times. However,
ChartDirector would still need to compute the same number of coordinates and use them to
draw the object. So the benefit may not be significant.
For using two threads, unluckily, in ChartDirector, the methods of a single object should be
called one by one, not concurrently. If you draw two charts, you can put them into two
threads. If you draw one chart, you can put the chart drawing code in one thread, and the
other parts of your program in another thread (such as another thread to display an
animated "waiting" icon).
Regards
Peter Kwan |
Re: 3D Graphs Class methods expansions |
Posted by Sal on Sep-29-2015 22:30 |
|
Thanks Peter for your replay.
With my example, I was trying to illustrate what else it is possible to use CharDir V6 for (Solid modeling with a little of creativity - a Sort of Surface and Filled Area plotting)
I knew the View had some viewing bugs, so your comments were of no surprise, since that project is a work in progress, in my spare time, while I am using extensively ChartDir for different 2D charts and other
What surprised me is that your programming team never saw the need to have into the Base Class a method like getXYCoor() I mentioned in my request, since you already have there a getXCoor() and getYCoor() method to obtain one of the 2 Pixels value.
Probably the above was due to Historical development issues, since the previous version of the library were more limited
In my view adding this method should not be a complex issue, since all the work has already been done. It is matter to have a new public method and call your protected methods that do the math.
I hope you tolerate the above presumptuous comment
I am certain that few other users would appreciate this addition as well
For flexibly, the ability to process an array of World coordinates points, all having the same X, since contained in one of the slices I used for illustration in my sample, would also, as I mentioned, greatly appreciated as well.
For abstraction, may be the array should be a list of 3D point or a couple of overloaded methods
Either way, I would take what you think is reasonable
I understand your comments about the 2 threads I asked about - Very helpful
Finally, please keep me posted if the above suggested library new features should materialize in a future version of CharDir Library (C++)
Lastly: It is possible to derive my own 3D class from ThreeDChart that would produce an array of filled area, without going to use the primitive methods I have been using ?
I can see it would have some of the functionality of ThreeDScatterChart
May be deriving and overriding some methods in ThreeDScatterChart would be a better choice
I am not certain if I would have all it is needed on hand and the above it is even possible
Thanks
Sincerely
Sal |
Re: 3D Graphs Class methods expansions |
Posted by Peter Kwan on Sep-30-2015 04:12 |
|
Hi Sal,
For the getXYCoor method, we know it is very logical, not just in 3D charts, but in polar
charts and to a certain extent in XY charts.
The issue we have is that we need an efficient API to return two values. It happens in
many programming languages, there is no robust and efficient method to return more than
one value. (For instance, how can one return two values in PHP or Java efficiently?) For
these programming languages, the overhead in returning two values will probably be much
higher than simply calling the method twice.
Since in practice, the efficiency loss in calling the method twice is minimal compared to
plotting the chart, so we end up using the same API in all programming language editions of
ChartDirector to allow us to port sample code and documentation more easily.
For derivng your own 3D class from ThreeDChart, I think it is better to derive it
ThreeDScatterChart. It should not be possible to derive from ThreeDChart at the API level.
Regards
Peter Kwan |
|