Add a primitive surface area function ... for right hyperbolic cylinders (RHC)BRL-CAD
Status: ClosedTime to complete: 72 hrs Mentors: SeanTags: C, C++, math, geometry, surface area

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 tricky to compute.

This task involves writing a new callback function that takes an rt_db_internal object and calculates the surface area (units are mm^2). There are numerous examples in our code where we compute surface area for other primitives. The primitives that do not already have a centroid callback are itemized in following.

References:

Code:

  • src/librt/primitives/rhc/rhc.c
Uploaded Work
File name/URLFile sizeDate submitted
rhcsurfarea.patch4.5 KBJanuary 06 2013 12:19 UTC
rhcsurfarea2.patch2.6 KBJanuary 08 2013 09:10 UTC
Comments
Dr Coconuton November 29 2012 20:43 UTCTask Claimed

I would like to work on this task.

Dr Coconuton November 29 2012 20:47 UTCSome questions...

The instructions are a little vague. I know C++ but am not to sure about how I should go about doing this task. I figure it's a good time to learn :)

Dr Coconuton November 29 2012 20:52 UTCClaim Removed

The claim on this task has been removed, someone else can claim it now.

Silvrouson December 4 2012 09:13 UTCTask Claimed

I would like to work on this task.

Andrei Popescu on December 4 2012 13:41 UTCTask Assigned

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

Daniel Rossberg on December 7 2012 12:34 UTCDeadline extended

The deadline of the task has been extended with 2 days and 0 hours.

Silvrouson December 8 2012 19:14 UTCbreadth vector

What does the breadth vector signify, exactly? Is its magnitude the distance from the vertex to the back rectangle?


 

Sean on December 8 2012 21:59 UTCsee appendix C

Near the end of our Intro to MGED is an appendix C that provides a graphical depiction of the RHC's parameters.  There you can see what B is in terms of the object's shape.  The B vector is described in more mathematical terms at the top of the rhc.c source file too.


http://brlcad.org/w/images/c/cf/Introduction_to_MGED.pdf


I would have called it the "height" of the curve from V.  Of course, I would have called the H vector the "depth" of the curve too.


See page 264.


 

Silvrouson December 9 2012 10:12 UTCsorry

I haven't finished yet, and I've clogged the task long enough, I'll let someone else take a stab at this while I try other tasks.

Silvrouson December 9 2012 10:12 UTCClaim Removed

The claim on this task has been removed, someone else can claim it now.

Richard Akira Heruon December 17 2012 08:14 UTCTask Claimed

I would like to work on this task.

Andrei Popescu on December 17 2012 08:21 UTCTask Assigned

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

Richard Akira Heruon December 20 2012 01:21 UTCClaim Removed

The claim on this task has been removed, someone else can claim it now.

Richard Akira Heruon December 21 2012 06:11 UTCTask Claimed

I would like to work on this task.

Sean on December 21 2012 06:56 UTCTask Assigned

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

Melange on December 24 2012 06:56 UTCInitial Deadline passed

Melange has detected that the initial deadline has passed and it has set the task status to ActionNeeded. The student has 24 hours to submit the work before the task is reopened and sent back to the pool for other students to claim.

Melange on December 25 2012 06:56 UTCTask Reopened

Melange has detected that the final deadline has passed and it has reopened the task.

Aaron Keesingon January 3 2013 13:09 UTCTask Claimed

I would like to work on this task.

Daniel Rossberg on January 3 2013 13:26 UTCTask Assigned

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

Aaron Keesingon January 4 2013 13:18 UTCArc Length

I believe that to work out the surface area you need to know the arc length of the cros-sectional hyperbola, but trying to work this out exactly involves incomplete elliptical integrals and other complicated calculus, and it might not even be possible to work out exactly.


The only solution I can think of is to try and approximate the arc length somehow, so that is is within a certain accuracy (so many d.p for example). Simpson's Rule may be one method of doing this. But I'm not sure what would be the best way to implement this in code (whether to write a separate function to do the aproximation of the integral, or do it in the main function). Apart from the arc length I think that the surface area will be relatively easy to compute.


Aaron K

Aaron Keesingon January 6 2013 12:19 UTCReady for review

The work on this task is ready to be reviewed.

Aaron Keesingon January 6 2013 12:30 UTCApproximation

I used Simpson's Rule to approximate the integral for arclength. Using the value of n=1000000 could slow things down on old hardware, but should give accuracy of 10d.p  or greater, from what I've tested (not in BRL-CAD).


The derivation of the formula is similar to that of the centroid for an ehy, and a lot of the code is similar to the code in that function. If necessary I can make another document with the derivation of surface area.


I haven't thoroughly checked all the code and all the math because I am in a little hurry but glancing over my notes everything seems to be correct.


Aaron K

Melange on January 6 2013 13:26 UTCNo more Work can be submitted

Melange has detected that the deadline has passed and no more work can be submitted. The submitted work should be reviewed.

Sean on January 6 2013 16:15 UTCjust need to document the magic number

Aaron, the only issue I see with the code is the need to document the 'n' magic number.  Any constants like that in the code need to be documented.  Separate that variable and include a comment to say what it is, why that value, what it guarantees, what values would be bad, etc.


 

Sean on January 6 2013 16:15 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.

Aaron Keesingon January 7 2013 09:50 UTCExtension required to upload

I can't upload the patch to this site unless an extension is given because the time has run out. Or would you rather I create a Sourceforge account and upload to the patch tracker?


Aaron K

Sean on January 8 2013 08:13 UTCDeadline extended

The deadline of the task has been extended with 2 days and 0 hours.

Sean on January 8 2013 08:14 UTCodd

Hm, you're supposed to be able to still upload for 24 hours after the time runs out.  No matter, extension done.

Aaron Keesingon January 8 2013 09:11 UTCReady for review

The work on this task is ready to be reviewed.

Sean on January 8 2013 19:39 UTCTask Closed

Congratulations, this task has been completed successfully.

Sean on January 8 2013 20:10 UTClooks great

Thanks Aaron, that looks good.  Your patch has been applied as r54145 (and you are already credited in our authorship documentation) with some minor changes.


For what it's worth, you usually want to avoid indentation levels if they're avoidable.  It's a minor stylistic point, but you'll usually want to validate your input parameters and exit early.


 

Sean on January 10 2013 06:21 UTCclose

Aaron, thought you might like to know that you're about four tasks close to making our top five list.  There are also about that many days remaining.