Adding a triangle calculation module to math?

Developers
Pete
2016-10-27
2016-10-28
  • Pete

    Pete - 2016-10-27

    Hi.

    I'm thinking about adding a module that performs all kinds of calculations about triangles. That should go to artofillusion.math. I have sometimes missed those methods as a ready package and there is a part in the view manipulation where this would be handy. I could of course add the methods into where they are used, but this way they'd be available to everybody.

    Now my question is how to name it? Triangle, TriangleCalc, TriangleMath, TriangleProps....

    EDIT:
    So far it calculates areas, normals, barycentric coordinates -- projects points on planes, interpolates between corners points... But it does not produce triangles, so it'd be a kind of a weird addition to AoI.math.

    -Pete-

     
    Last edit: Pete 2016-10-27
  • Peter Eastman

    Peter Eastman - 2016-10-27

    What sort of API do you have in mind? That will affect what name makes sense.

    For example, one option would be that you create an object representing a triangle, then call methods on it to compute properties. In that case, Triangle would make sense. You would create a Triangle object, then call methods like getArea() and getNormal().

    Alternatively, you could have a class that just provides a lot of static methods along the lines of java.lang.Math. In that case, calling it TriangleMath would make more sense.

     
  • Pete

    Pete - 2016-10-27

    At the moment, it is more like the latter one. There are methods that take a RenderingTriangle or it's corner points (and sometimes something more) as inputs and then returns something.

    After posting the question I started to think more seriously about the triangle object possibility. That would seem to fit better the thinking in AoI.math and I could imagine that there would be some other benefits to it as well... Like the possibility of storing the information inside the objects.

    Looks like, I'll put that aside for a moment and possibly make it separate project later.

     
  • Luke S

    Luke S - 2016-10-28

    My first thought is that the static method version might be more generally useful.

    There are already two triangle 'types' in AOI, (RenderingTriangle in all of its sub-variants and TriangleMesh.Face) Each optimized for its specific use.

    Anyone using a the triangle utilities would almost certainly be working with groups of one or the other. Forcing creation of another object would have the potential for spaming the GC with a lot of short-lived objects, just to operate on some data that you already have in a handy package.

    Some of the other ArtOfIllusion.math classes, such as RGBColor, and the vector types, are very simple, minimalist objects that can be used just about anywhere. I'm not sure that you would use a triangle object in the same way.

     
  • Pete

    Pete - 2016-10-28

    My first thought is that the static method version might be more generally useful.

    After bouncing the idea forth and back, I think you are right. So 'TriangleMath' it is!

    Forcing creation of another object would have the potential for spaming the GC with a lot of short-lived objects

    This is one thing, I thougt of.... Doing that physical properties script I noticed, that it left a lot of garbage behind and filled all the available memory before CG started to work -- and when that happened that of course was consuming processing time. -- So defining yet another object would only make it worse.

    The triangle object would more or less have to become a wrapper for the existing triangles and it would have to provide another triangle type (basically a 'dumb' triangle with only corners defined) for other purposes, so it does not really make much sense. -- Maybe there could be a Triangle to facilitate the use of TringleMath some time in the future, but not now. :)

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks