Implement a primitive centroid function ... for elliptical hyperboloids (EHY)BRL-CAD
Status: ClosedTime to complete: 72 hrs Mentors: Sean, Matt S.Tags: C, C++, math, geometry, centroid

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 its centroid (as a point_t 3D point). There are numerous examples in our code where we compute centroids for other primtiives. The primitives that do not already have a centroid callback are itemized in following.

References:

Code:

  • src/librt/primitives/table.c
  • src/librt/primitives/ehy/ehy.c
Uploaded Work
File name/URLFile sizeDate submitted
ehycentroid.patch1.2 KBDecember 19 2012 10:16 UTC
ehycentroid2.patch1.5 KBDecember 20 2012 00:36 UTC
Comments
Alex Ozeron November 28 2012 02:54 UTCTask Claimed

I would like to work on this task.

Sean on November 28 2012 02:55 UTCTask Assigned

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

Alex Ozeron November 30 2012 22:58 UTCExtension

I've been busy with schoolwork recently, is there any chance to get an extension on this task?

Melange on December 1 2012 02:55 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.

Alex Ozeron December 1 2012 03:11 UTCClaim Removed

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

Sean on December 1 2012 08:59 UTCsure

Yes, an extension can be or could have been granted.  You just unclaimed it too quickly. ;)


Of course, you can always claim it again if nobody else does.

Rita Navarroon December 1 2012 15:47 UTCTask Claimed

I would like to work on this task.

Rita Navarroon December 1 2012 15:50 UTCClaim Removed

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

Richard Akira Heruon December 6 2012 14:47 UTCTask Claimed

I would like to work on this task.

Sean on December 6 2012 14:47 UTCTask Assigned

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

Melange on December 9 2012 14:47 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 10 2012 14:47 UTCTask Reopened

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

Aaron Keesingon December 16 2012 07:59 UTCTask Claimed

I would like to work on this task.

Harmanpreet Singh on December 16 2012 09:14 UTCTask Assigned

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

Aaron Keesingon December 18 2012 09:20 UTCFinding Centroid

I believe I may have found a general formula for finding the centroid of the hyperboloid, if it is oriented nicely and I can work out the equation. I couldn't find any  specific formula for a hyperboloid's centroid on the internet, so I am trying to use some general formulas for finding the centroid of any shapes, then using the equation of the cross-sectional hyperbola to find its centroid, and taking advantage of the hyperboloid's symmetry.


Could you please indicate whether I am on the right track or if I am getting way off with this method, or am I missing something completely obvious?


I may need an extenstion on this task as I am also doing holiday work for school and am only able to work on this in the evenings, but I'll see how I get on.


Thanks


Aaron K

Sean on December 18 2012 14:16 UTCcenter?

So oriented nicely, the elliptical hyperboloid is elliptical.  You know the center of the elliptical part is the center of the ellipse, so you can immediately constain your solution to the center of a bounded hyperbola, no?  You also know that the centroid will be on the centerline of the hyperbola due to symmetry.  That greatly simplifies the problem, no?  I'd bet someone's already done the math on answers.yahoo.com for some homework assignment. ;)


 


 

Sean on December 18 2012 14:16 UTCDeadline extended

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

Aaron Keesingon December 19 2012 10:17 UTCReady for review

The work on this task is ready to be reviewed.

Aaron Keesingon December 19 2012 10:21 UTCMessy

I'm sorry if the code looks messy, both math-wise and code-wise. I believe the seemingly complicated math is what is necessary to find the centroid.


On the other hand, the numerous variables in the code are so it doesn't get even more messy than it already is! If there is anything I could change from a code perspective to make it more efficient or less messy, please tell me.


Thanks


Aaron K

Daniel Rossberg on December 19 2012 12:41 UTCIssues


  • Your patch doesn't follow our coding guidelines (see the HACKING file) particularly w.r.t. the indentation levels (4 spaces, 1 tab, 1 tab plus 4 spaces, 2 tabs, ...).

  • Please update table.c too.

  • RT_HYP_CK_MAGIC ???

Daniel Rossberg on December 19 2012 12:41 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 December 20 2012 00:37 UTCReady for review

The work on this task is ready to be reviewed.

Daniel Rossberg on December 20 2012 08:02 UTCOne open point:

Could you please provide us a document where you describe your formula?  I.e. basic methodology and equations and how you derived your formula from this?


The source code looks ok so far.

Daniel Rossberg on December 20 2012 08:02 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.

Melange on December 21 2012 02:40 UTCTask Reopened

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

Sean on December 21 2012 02:43 UTCreclaim it

Aaron, you're encouraged to reclaim the task so we can mark you as having completing it.   Even a picture of a piece of paper where you worked out the math would be good.  It would be great to include the derivation in the source code comments. ;)


 

Aaron Keesingon December 21 2012 04:56 UTCTask Claimed

I would like to work on this task.

Sean on December 21 2012 05:00 UTCTask Assigned

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

Aaron Keesingon December 21 2012 12:05 UTCCentroid Derivation

Here is the link to a document which hopefully explains how I derived the formula.


https://docs.google.com/open?id=0BydeQ6BPlVejRWt6NlJLVDl0d28


Sean, I'm not sure how I would include such a lengthy derivation in comments in the source code. Perhaps I could simply put a link to the above document maybe?


Aaron K

Aaron Keesingon December 21 2012 12:05 UTCReady for review

The work on this task is ready to be reviewed.

Daniel Rossberg on December 22 2012 18:46 UTCTask Closed

Congratulations, this task has been completed successfully.

Sean on December 28 2012 09:05 UTCin the comments

Aaron, that looks fantastic, but it certainly could be included in the source code comments.  See http://brlcad.svn.sourceforge.net/viewvc/brlcad/brlcad/trunk/src/librt/primitives/ehy/ehy.c for an example of another primitive with equations, definitions, and derivations spelled out.


 

Aaron Keesingon January 1 2013 02:11 UTCComments Patch

Since I cannot upload more files, here is the link to the patch containing the brief derivation in the comments.


https://docs.google.com/open?id=0BydeQ6BPlVejbkQ1VW1Laktka1E


I tried to make it as short as possible while still being able to understand, but have included a link the document as well.