
Comments and Discussions



thx~~





For example:
return this[ row*4 + column ];  must be, for 4dimensional, but now
return this[ row*2 + column ];
I think it's copypaste from 2dimensional matrix.





Your algorithm for public static ComplexD Sqrt(ComplexD a) is incorrect.
I checked results against both MATLAB and a C library called MPC which uses GMP and MPFR as base libraries. I program in Eiffel mostly and rewrote your function in that language as I needed something similar. I have a reasonable understanding of C# and don't think I made any errors in my adaptation.
I did a search and found an article in Wikipedia which I used to make corrections. My changes caused my function to agree with MPFR and MATLAB.
Hope this helps. I have not examined other functions in your library but you may need to do some checks.
Hope this is helpful.
Regards
Chris Saunders
evas@mountaincable.net





Chris,
Could you share the fixed code with us?
Eric





It has been quite some time since I was working with this and I cannot find the code I adapted. I'm going to enter a pseudo C code version here that I believe is correct. It should be fairly simple to adapt this to C#(I do know some C# but don't use it much so I'm doing this to avoid errors).
This will calculate the principle square root of a complex number. I'm going to represent a complex number as an ordered pair of real numbers (x, y).
pow() is the power function from math.h
sqrt() is the square root function from math.h
double r = sqrt(pow(x, 2) + pow(y, 2));
(x, y) = (sqrt((r + x) / 2), y / sqrt((2 * (r + x))));
Hope this is sufficient.
Regards,
Chris Saunders
evas@mountaincable.net





Dear Eran,
Your work is very interesting. I used it in an experimental OO application for manipulating 3Dstructures in the field of mechanical engineering, providing some specialized CAD addons. It saved me many hours of programming. Especially the rotation matrix generation for rotation about an arbitrary axis is great. C++ takes a lot more time for what I did (I think).
Indeed not much code is freely available dealing with this kind of math...sometimes I ask myself the question if C# is ever going to survive / grow in this field.
O yeah: I wonder why your website is currently unavailable...
Again: Thanks! Really appreciate it!
Greeting from The Netherlands,
Johan





Hi,
I'm just starting to use C# and I'm wondering how do I install this library and use it in my project. I tried to put binaries into C:\WINDOWS\Microsoft.NET directory, but it didn't work, and there's no 'include' directory in C# as it is in C++. Please assist or point in the right direction.
Thanks.
"Do not try. Do"





You can just put the library DLL anywhere and reference to it from there (rightclick opn your project and choose "Add Reference")
Eran Kampf
eran@ekampf.com
http://www.ekampf.com





You can check out the updated version at http://www.ekampf.com/Sharp3D.Math/
and at my blog at http://www.ekampf.com/blog/
Eran Kampf
eran@ekampf.com
http://www.ekampf.com





Hi Eran,
I'm just using your newest version of the library and have a few remarks:
 The random number generators use virtual methods and an abstract base class. Can you convert the base class into an interface and not use virtual methods for performance?
 I want to generate random Vector3F's, so it would be nice for performance if there was a way of directly generating a Vector3F object in stead of first filling a float[3] array and then creating a Vector3F object from that.
 It would be nice if Matrix4F had an overload of Transform that gets/returns a Vector3F object (we discussed that once I think).
I can do the changes myself too if you tell me how you would like them.
Kind regards,
Wout





1. You're right. I will turn the RandomNumberGenerator to an interface.
2. If you're creating several Vector3F instances you should create a float[3*numberOfVectors] and initialize the vector's from it... or you can use the RandGenMT class directly and class NextDouble()....
3. I'll the Matrix4F overload...
Im going to release a new revision of the library in the next few days (minor fixes to v1.1.2) so these changes will be included there...
How's the ray tracer going?
Eran Kampf
eran@ekampf.com
http://www.ekampf.com





Hey Eran,
I was wondering why you don't give any credit to Exocortex.DSP and Exocortex.Geometry3D as the basis for your Sharp3D.Math library? I was looking through your new library and while I think the work you've done is impressive I was sort of shocked to see how much of the code I recognize from my own math libraries.
For example the following classes in Sharp3D.Math seem to be at least partially derived their counterparts in Exocortex.DSP, Exocortex.Geometry3D or Exocortex.Mathematics classes.
ComplexD > ComplexD
ComplexF > ComplexF
Vector3F > Vector3D
Vector3D > Vector3D
VectorArrayLists > Vector3DCollection
Plane3F > Plane3D
QuaternionD > Quaterion
QuaternionF > Quaterion
Matrix4F > Matrix3D
Matrix4D > Matrix3D
Polygon > Polygon3D
SimpsonIntegral > SimpsonIntegral
MathFunctions > ( SimpleArray, ComplexArray, ComplexStats )
And every so often I notice code that is copied outrigth from the Exocortex libraries into the Sharp3D.Math library. For example the following is the GetIntersection function from Sharp3D.Math.Geometry3D.Plane:
public Vector3F GetIntersection(Vector3F p0, Vector3F p1) {
Debug.Assert( IsIntersection( p0, p1 ) == true );
Vector3F Direction = p1  p0;
float denominator = Vector3F.DotProduct( Normal, Direction );
if( denominator == 0 ) {
throw new DivideByZeroException(
"Can not get the intersection of a plane with a line when they are parallel to each other." );
}
float t = ( Constant  Vector3F.DotProduct( Normal, p0 ) ) / denominator;
return p0 + Direction * t;
}
Here is the code from the GetIntersection function I wrote for Exocortex.Geometry3D.Plane3D:
public Vector3D GetIntersection( Vector3D pt0, Vector3D pt1 ) {
Debug.Assert( IsIntersection( pt0, pt1 ) == true );
Vector3D ptDirection = pt1  pt0;
float denominator = Vector3D.Dot( Normal, ptDirection );
if( denominator == 0 ) {
throw new DivideByZeroException(
"Can not get the intersection of a plane with a line when they are parallel to each other." );
}
float t = ( Constant  Vector3D.Dot( Normal, pt0 ) ) / denominator;
return pt0 + ptDirection * t;
}
I don't know about you but the above two code snippest look incredibly similar to me  just the variables names have been slightly changed. This is just one instance of many uncanny similarities between your "new" code base and the ones I released a couple years back.
Thus in closing, I do congratulate you on the many new classes and polish you've put on the existing classes. Although, I would ask a favor of you: could you add back my name as well as the original BSD open source license to the classes you derived originally from my Exocortex mathematics libraries?
Kind regards,
Ben Houston
http://www.exocortex.org/ben





Actually,
The naming and general concept (epsecially the MathFunction class) is derived from CenterSpace's NMathCore library.
As for the core structure's float\double naming, the library was originaly float only (Vector3, Matrix3 etc..) when the need for doubleprecision structures came, I decided to use OGLlike notation (maybe you should google for 'vector3f', apperantly many copied Exocortex naming convention).
The design behind the core structures is that all implement ISerializable and ICloneable, Parse static method and that all arithmetics is represented by static methods so that languages without operator overloading can use them. The structures resemble only by name a general functionality.
All the typed collections in Sharp3D.Math were generated using CodeSmith and have absolutely nothing to do with Exocortex.
SimpsonIntegral is a class using the simpson integration method so its name seems to fit its purpose (dont you think?).
The code isn't the same so whats your point?
Basically, most of the library's code is derived from work I've done, stuff at work etc... So, some snippets may have been derived from your library but I cant track back any code snippet I use.
As for the above snippet I am happy to invorm you version 1.1.3 of the library contains a redewsigned Plane structure without the above snippet.
So to conclude:
1. The library was NOT built based on Exocortex.Geometry3D. It doesnt derive from it or polishes its classes. It is based on my my own code and my own design. I didn't even hear about Exocortex.DSP and Exocortex.Mathmatics untill this post.
2. If there are other snippets you think that derive from one of your libraries be sure to let me know, I will be happy to add your name to the credits.
3. Usually when programming a class for a math structure you name the class after the math structure it represents (Vectors, Matrix etc..). I think thats a concept most programmers use regardless of Exocortex.
4. This post seems like a lame attemp to create some sort of "scandal".
You already tried this a while ago...
Eran Kampf
eran@ekampf.com
http://www.ekampf.com





The main SimpsonsIntegral function in my Exocortex.Mathematics.SimpsonsIntegral:
double sum=0;
double step_size=(ba)/step_number;
for(int i=0;i<step_number;i=i+2) sum=sum+(f(a+i*step_size)+4*f(a+(i+1)*step_size)+f(a+(i+2)*step_size))*step_size/3; return sum;
The main SimpsonsIntegral function in your Sharp3D.Math.Core.SimpsonsIntegral:
double sum = 0;
double stepSize = (ba)/_stepsNumber;
double stepSizeDiv3 = stepSize/3;
for (int i = 0; i < _stepsNumber; i = i+2)
{
sum += (f.Function(a + i*stepSize) + 4*f.Function(a+(i+1)*stepSize) + f.Function(a+(i+2)*stepSize))*stepSizeDiv3;
}
return sum;
Again most of the code is the same  the same variable names: a, i, f, the same order of operations and the brackets are even the same. You've just changed step_size to stepSize, f() to f.Function() and pulled out the variable stepSizeDiv3 from the loop. In other words much of your library, which you are claiming to be original, is a refactoring of mine.
Ben Houston
http://www.exocortex.org/ben





Sharp3D.Math defines an analysis framework which includes an interface for Integration and Differentiation and a class that represents a function that takes one parameter and alows operating on this function (Integrating, Differentiating and in the future I hope to add the ability to add' subtract etc such functions)
Anyway, the framework includes several implementations for integrations (IIntegrator implementations) and among them is the SimpsonIntegral class.
Exocortex.Mathematics on the other hand contains a Simpson Integral class which takes a simple delegate as a parameter.
Yet, both of us calculate the integral the same way (I wonder why)...
Thats SOME refactoring isnt it?
Infact let me save you some posting work.
I bet my vector cross product method looks pretty much like yours too...
I bet my matrix multiply method looks like yours too...
And even without checking the code I can bet both of us represent a complex number using two floats\doubles and call one "imaginary" and one "real"...
so
1. I wont credit you for the simson law thing... I think its Simpson who deserves the credit for that.
2. You didn't paste the complete code of my method. The line "if (a > b) return Integrate(f, b, a);" should be at the beginning. I will allow to use this special line in your code to avoid errors, feel free to credit me.
3. I Googled for "step_number" and found several other guys using the ingenius variable name, some of them event to calculate Simpson's law.
(example here)
I suggest you go bother them....
Eran Kampf
eran@ekampf.com
http://www.ekampf.com





After I initially contacted Eran about this he said:
"Look, the only thing I might have "stolen" from your library is some design ideas (the static Create* and Min* functions) and the Sign handling in the math library."
After I pointed out a bunch more code similiarities he responded:
"if it makes you happy I cpied[sic] point and modified it to my needs.
You can contact whoever you want... this discussion is over as far as I am concerened..."
Thus from Eran's perspective he admits that he used Exocortex as a basis for his library (if the two above code similarities weren't enough) but it isn't relevant that he removed all references to Exocortex from the headers. From his perspective I am just being vindictive since I am complaining about what he admits to doing.
Ben Houston
http://www.exocortex.org/ben





Sharp3D's design isnt based on Belief3D (which is the project you are reffering too) and certainly isnt based on your code...
Oh, you forgot to mention this was regarding a different project and happend almost a year ago...
And as I remmember, in that case you even bothered to contact my host (flipcode.com) to remove my web site.
Even he had to check out your claims and find them to be bogus...
Just another lame attemp to attract attention and recieve credit you do not deserve.
Eran Kampf
eran@ekampf.com
http://www.ekampf.com





You both need to be aware of the fact that open source code is intended to be governed by an applicable license that blends the concept of intellectual property and contract law in a way that has yet to be fully judicially tested. As of this date, No U.S. court has ruled on whether the GNU GPL or any other open source code license is an enforceable contract. In the case of Progress Software Corp. v. My SQL AB, 195 F. Supp. 2d 328 (D. Mass. 2002), the only U.S. case so far in which an open source code licensor sought an injunction, the court did not reach the issue of enforceability of the license. Instead, the court simply held that the licensor had not shown a likelihood of success on the Merits, nor had the licensor shown Irreparable harm.
Neither of you can claim Patent Rights, Copywrites, or Intellectual Property Rights to either the form or substance of Source Code or the GPL License so both your arguments are baseless.
Copyright, Intellectual Property Rights, and Licensing Issues
http://sunsite3.berkeley.edu/copyright/





Hey,
Thanks for the link... There's some interesting reading there...
Eran Kampf
eran@ekampf.com
http://www.ekampf.com





I was looking for a (2D) geometry library and stumbled on this. It looks very good.
Due to my own past experiences I was interested to read this discussion on supposed use of code from Exocortex libraries.
I thought perhaps an independent assessment was in order. Hopefully, I am unbiassed but I should disclose that I have had the unfortunate experience of someone blatantly copying freely distributable source code I wrote (the original version of my hex editor) and selling it as shareware. On the other hand, I have been unjustly accused of plagiarising someone else's idea  something I categorically deny, Steve.
Anyway I downloaded the source code of both Sharp3D.Math and Exocortex and analysed some of it starting with the abovementioned "GetIntersection" function. Superficially that function looks similar, but it seems possible, if unlikely, that the similarity is coincidental. After all the code solves exactly the same problem and there are common conventions for naming variables adopted by mathematicians and programmers.
However, closer inspection shows that both versions of "GetIntersection" are almost certainly related. Either one is derived from the other, or they have a common ancestor. For example, the use of spaces and tabs is exactly the same in both functions  note the tab character between "return" and "pt0". I have found other, even more striking, examples in other areas of the code.
Another thing to note is that the Sharp3D.Math code has many lines ending with single space characters before a line containing an open brace character "{". This indicates that the code has been converted from the convention of braces on the end of lines (as used in Exocortex.Geometry3D library) to the convention of braces on the line below. For example, both opening braces in "GetIntersection" in Sharp3D.Math have this space character at the end of the previous line. This strongly indicates that the Exocortex is not derived from Sharp3D.Math, ie Sharp3D.Math is derived from Exocortex, or they have a common ancestor.
I also note that variable names, strings and comments have been changed slightly. Whether this is an attempt to disguise the origin of the code or was just part of some cleanup is arguable.
Andrew Phillips
aphillips @ expertcomsoft.com





Hi Eran,
Just a note that I've been using your library in my light distribution calculation application and it works pretty well and is full featured.
I'm now considering adding a small ray tracer for computing reflections/shadows, maybe I'll add it to either your project or CodeProject.com.
Thanks,
Wout





I launched my new homeapge at http://www.ekampf.com
You can check out the sharp3d.math information there and also browse the documentation online.
Eran Kampf
eran@ekampf.com
http://www.ekampf.com





This library you have is excellent work. The article could use a little work to make this absolutely outstanding.
Firstly, a small demonstration of the library would be wonderful. It is always nice to work from an example to see how to get something working quickly. Hopefully you can add this.
Secondly the class documentation has some gaps and I feel that more use of the <remarks> section would be good for explaining a bit more. I know that as a developer working on the project that everything becomes intuative to you, but others don't have that level of knowledge yet.
Lastly, the article itself could be extented to show how to put together some samples, or to explain the workings of the library. Or even explain the differences between 2D and 3D elements (that would be interesting to me as I've worked with 2D graphics and anaysis in the GIS field but I've not done anything with 3D)
I hope this helps. I see you've already got a great score (4.05 at the time of writing) and this can only get better.
Keep up the great work.
"You can have everything in life you want if you will just help enough other people get what they want." Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog





1. I will include the code for the Sharp3D.Math unit tesing library. It should supply some basic code samples for working with the library.
As for a sample application I started working on a basic ray tracer but it'll take some time to finish...
2. Can you specify where exactly you think the documentation is lacking?
3. I will try to add some more content to the article. Cover the basic structures (vectors, matrices, complex numbers) etc. but its all pretty much straightforward and I wouldnt want to write stuff just to make the article's line count higher.
Thanks for the comments...
Eran Kampf
tentacle@zahav.net.il





Eran Kampf wrote:
As for a sample application I started working on a basic ray tracer but it'll take some time to finish
That sounds great.
Eran Kampf wrote:
Can you specify where exactly you think the documentation is lacking?
Well, like I said, it could use more <remarks> sections. Take a look at MSDN to see what they have. There are some items that do have a remarks section, but all they seem to say is "See xxx for details". I guess I am so used to reading MSDN, and because NDoc produces documentation that looks like MSDN I want to see the same kind of things.
Eran Kampf wrote:
I will try to add some more content to the article...but its all pretty much straight forward and I wouldn't want to write stuff just to make the article's line count higher.
Pick an area that is interesting to you (remember it isn't straight forward to everyone), or produce a tutorial style for the ray tracer demo to explain how it is put together and how all the components hang together.
When I read an article I generally read the top couple of paragraphs, and if it seems to be interesting I'll scroll to the bottom to see how much there is. Sometimes, if it is long, I'll bookmark it and come back when I have more time. If it is too short I sometimes won't go any further because I hate digging through code with no explanation of where to start or what bits are core.
I hope this helps. It looks like you have an excellent library and I would very much like to have the time to explore it further.
"You can have everything in life you want if you will just help enough other people get what they want." Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog







General News Suggestion Question Bug Answer Joke Rant Admin Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

