Implement a volume function for superellipsoids (SUPERELL)BRL-CAD
Status: ClosedTime to complete: 72 hrs Mentors: SeanTags:

BRL-CAD provides more than two dozen types of geometry ''primitives'' such as ellipsoids, boxes, and cones. Every primitive is described by a collection of callback functions, for example rt_ell_bbox() returns the bounding box dimensions for an ellipsoid. Wikipedia, Wolfram Mathworld, and various other math sites (and research papers) around the web include the equations for most of our basic primitives while others are a little more difficult to compute.

References:

  • http://en.wikipedia.org/wiki/Volume
  • http://mathworld.wolfram.com/
  • http://www.dtic.mil/cgi-bin/GetTRDoc?AD=AD0274936
  • include/raytrace.h: See ft_volume callback defined in rt_functab structure

Code:

  • src/librt/primitives/superell/superell.c (implement your function here)
  • src/librt/primitives/table.c (add a reference to your function here)

This task involves writing a new callback function that takes an rt_db_internal object and calculates the volume (units are mm^3). There are numerous examples in our code where we compute volume for other primitives. Submit a patch file the may be applied cleanly.

If you succeed, a follow-on task may be created to enable and validate your function.

Uploaded Work
File name/URLFile sizeDate submitted
superell-volume.patch1.3 KBNovember 29 2013 08:09 UTC
superell-volume2.patch1.5 KBNovember 30 2013 00:57 UTC
Comments
agkphysicson November 29 2013 03:20 UTCTask Claimed

I would like to work on this task.

Harmanpreet on November 29 2013 03:24 UTCTask Assigned

This task has been assigned to agkphysics. You have 72 hours to complete this task, good luck!

agkphysicson November 29 2013 04:13 UTCBeta or gamma functions

I have found a formula for the volume from http://en.wikipedia.org/wiki/Superellipsoid, but to calculate it requires the use of the beta function or gamma function. It looks like BRL-CAD doesn't have this function defined in one of its libraries, so I will have to write my own. I'm worried about licensing issues if I copy the source code from some of the examples on the internet.


An example written in Python here: http://en.wikipedia.org/wiki/Lanczos_approximation looks like it could work if I ported it to C, but how would I source it? Should I just write this as a function in superell.c and use it to calculate the volume?

agkphysicson November 29 2013 04:18 UTCGamma function

Woops! It looks like the C Math library already has a function defined to compute the gamma function; I didn't notice that.

agkphysicson November 29 2013 08:09 UTCReady for review

The work on this task is ready to be reviewed.

Daniel Rossberg on November 29 2013 12:20 UTCPatch base directory

The code looks OK, but the patch's base directory should be the BRL-CAD source tree home directory.  I.e. the file references in the patch file should look like "src/librt/primitives/superell/superell.c".


I like your comment on how you got the formula for rt_ehy_volume().  Would it be possible to comment rt_superell_volume() in a similar way?

Daniel Rossberg on November 29 2013 12:20 UTCTask Needs More Work

One of the mentors has sent this task back for more work. Talk to the mentor(s) assigned to this task to satisfy the requirements needed to complete this task, submit your work again and mark the task as complete once you re-submit your work.

agkphysicson November 30 2013 00:47 UTCVolume

I got the volume function from http://en.wikipedia.org/wiki/Superellipsoid, but there is also an equivalent formula here which includes a derivation.


Since they follow the same general formula, I will use the formula with the derivation and put a link to the document in the source.

agkphysicson November 30 2013 00:59 UTCReady for review

The work on this task is ready to be reviewed.

Sean on December 1 2013 04:32 UTCexcellent

agkphysics, this is fantastic work.  Obviously won't know if it's technically correct or not for some time, but it looks like an excellent implementation: you've researched and utilized relevant research and the patch applies cleanly.  Can't ask for more from a GCI task (though we can and plan to create several follow-on tasks if you're interested).


Your change was applied to our trunk sources in r58719 and you've been credited in our authorship documentation.  If you provide your full name (publicly or privately), we'll credit you more appropriately (great for your resumé).

Sean on December 1 2013 04:32 UTCTask Closed

Congratulations, this task has been completed successfully.

Sean on December 1 2013 04:33 UTCmailing list

agkphysics,


If you've not yet subscribed, I encourage you to subscribe to our brlcad-news mailing list to keep in touch: https://lists.sourceforge.net/lists/listinfo/brlcad-news


I also encourage you to join our brlcad-devel list too if you intend to keep developing for BRL-CAD, and I hope you do!


 

agkphysicson December 1 2013 07:19 UTCAuthorship

As I mentioned in another task, my full name is Aaron Keesing, and it looks like I am already included in your AUTHORS file because of last year's GCI work.


And yes I would be interested in some follow on tasks.