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.
File name/URL | File size | Date submitted | |
---|---|---|---|
superell-volume.patch | 1.3 KB | November 29 2013 08:09 UTC | |
superell-volume2.patch | 1.5 KB | November 30 2013 00:57 UTC |
I would like to work on this task.
This task has been assigned to agkphysics. You have 72 hours to complete this task, good luck!
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?
Woops! It looks like the C Math library already has a function defined to compute the gamma function; I didn't notice that.
The work on this task is ready to be reviewed.
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?
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.
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.
The work on this task is ready to be reviewed.
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é).
Congratulations, this task has been completed successfully.
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!
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.