C# Geometry library

Does anyone know of a good basic geometry library for C# that does things like returning the distance of a point from a line, and line line intersections etc?

I could use the microstion ones, but that will be a big speed drag, or i could write them myself, but that'd be sketchy as my maths is pretty bad.

Any ideas?

Parents
  • High-Performance 3D Geometry

    Ben:
    Does anyone know of a good basic geometry library for C# that does things like returning the distance of a point from a line, and line line intersections etc? I could use the MicroStation ones, but that will be a big speed drag, or i could write them myself, but that'd be sketchy as my maths is pretty bad.

    Most of MicroStation's essential innards, unsurprisingly, are compiled to native code. Since the geometry library is vital to MicroStation's performance, and has been evolving for twenty years, it's probably faster than you or I could write.

    So why do you write that the MicroStation library will be a big speed drag? C# runs, interpreted, on the .NET CLR, which is not exactly renowned for its performance.

    If performance is an issue, avoid inefficient run-time performance sinks: stick to native code, meaning the MicroStation Development Library and C++.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Reply
  • High-Performance 3D Geometry

    Ben:
    Does anyone know of a good basic geometry library for C# that does things like returning the distance of a point from a line, and line line intersections etc? I could use the MicroStation ones, but that will be a big speed drag, or i could write them myself, but that'd be sketchy as my maths is pretty bad.

    Most of MicroStation's essential innards, unsurprisingly, are compiled to native code. Since the geometry library is vital to MicroStation's performance, and has been evolving for twenty years, it's probably faster than you or I could write.

    So why do you write that the MicroStation library will be a big speed drag? C# runs, interpreted, on the .NET CLR, which is not exactly renowned for its performance.

    If performance is an issue, avoid inefficient run-time performance sinks: stick to native code, meaning the MicroStation Development Library and C++.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Children
  • Thanks Jon, I forgot the last (and probably most important) constraint on not using microstation libraries. I'm hoping to use microstation to prototype the code, and then port it to a stand alone app.

    If the MS libraries are fast then i might end up using them anyway. It's not really going to be a mega performance drag  but my concerns come from using acad and rhino to do similar things, and it takes an age to call any of their functions.

    I'd like the end point to be a WPF application, more for my own whim than for any preference over DX or Open GL.

  • Ben:
    I'd like the end point to be a WPF application, more for my own whim than for any preference over DX or Open GL.

    If you investigate a little deeper, then I think you'll find that Microsoft WPF is a wrapper around Microsoft DirectX.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Ben:
    The last (and probably most important) constraint on not using microstation libraries. I'm hoping to use MicroStation to prototype the code, and then port it to a stand alone app.

    If you're in a Microsoft world, then no doubt there are C#/DirectX libraries that do what you want. Search the web for C# 3d geometry. Google Results: about 368,000 for C# 3d geometry.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • At the moment, it's actually only 2d that I'm after, and I'd assumed that geometry would just be a generic math library, but it seems that anyone who takes geometry seriously (mostly gamers) does it in c++, and it's proving tricky to find a simple library.

    cgal is overkill for this, but wykobi looks good, I'll investigate.

     

     

     

  • For simple geometry is better to make own assembly. Don't forget that not only Bentley, Microsoft or anybody else can build assembly, but U2 :)) . The best bet is to code assembly in C++ and then use it in C# as much you need. And if you find some geometry functions writen in C++ on internet, don't tell me that it is hard to rewrite it into C#. If not used pointers, usually you can solve it by copy/paste... What functions exactly you need? I have made some in old MSBasic, because there isn't any library :)) .
  • I found one nice C# example full of good geometry functions. It is OpenSource app. NASA World Wind and if you download source, you can find inside a lot of useful functions or at least some inspiration.
  • You might want to check out CodePlex www.codeplex.com. In case you're not familiar with it, CodePlex is an open source project site sponsored by Microsoft. Search the tags for C# and geometry but also don't overlook the GIS projects like SharpMap. Besides all the 3D coordinate transformation stuff we usually think of in GIS, a lot of 2D geometry is required as well.

    Also check out Google Code (code.google.com), the Google sponsored project site. You may need a Subversion client to grab the code you want but in most cases, you can just browse the algorithm lines to see if it's what you're looking for.

    Who knows; you might just find a project that fits your interest and you can contribute some of your own expertise.

    Regards,

    Charles Griffith