Hi,
I doubt whether the part primitive is defined in that way. If you raytrace it,
you will find it slightly different from what you see from the draw command.
Cheers!
Wu
------------------ Original ------------------
From: "crdueck"<crdu...@users.sourceforge.net>;
Date: Fri, Jul 6, 2012 08:09 AM
To: "brlcad-commits"<brlcad-comm...@lists.sourceforge.net>;
Subject: [brlcad-commits] SF.net SVN:
brlcad:[51436]brlcad/trunk/src/librt/primitives/part/part.c
Revision: 51436
http://brlcad.svn.sourceforge.net/brlcad/?rev=51436&view=rev
Author: crdueck
Date: 2012-07-06 00:09:14 +0000 (Fri, 06 Jul 2012)
Log Message:
-----------
added rt_part_volume() and rt_part_surf_area()
Modified Paths:
--------------
brlcad/trunk/src/librt/primitives/part/part.c
Modified: brlcad/trunk/src/librt/primitives/part/part.c
===================================================================
--- brlcad/trunk/src/librt/primitives/part/part.c 2012-07-05 22:35:00 UTC
(rev 51435)
+++ brlcad/trunk/src/librt/primitives/part/part.c 2012-07-06 00:09:14 UTC
(rev 51436)
@@ -1813,6 +1813,56 @@
}
+/**
+ * R T _ P A R T _ V O L U M E
+ */
+void
+rt_part_volume(fastf_t *vol, const struct rt_db_internal *ip)
+{
+ fastf_t vrad, hrad, mag_h;
+ struct rt_part_internal *pip = (struct rt_part_internal *)ip->idb_ptr;
+ RT_PART_CK_MAGIC(pip);
+
+ vrad = pip->part_vrad;
+ hrad = pip->part_hrad;
+ mag_h = MAGNITUDE(pip->part_H);
+
+ if (EQUAL(vrad, hrad)) {
+ *vol = M_PI * vrad * vrad * (4.0/3.0 * vrad + mag_h);
+ } else {
+ fastf_t vrad3, hrad3, mid_section;
+ vrad3 = vrad * vrad * vrad;
+ hrad3 = hrad * hrad * hrad;
+ mid_section = M_PI * mag_h * (hrad * hrad + vrad * vrad + hrad * vrad)
/ 3.0;
+ *vol = 2.0/3.0 * M_PI * (vrad3 + hrad3) + mid_section;
+ }
+}
+
+
+/**
+ * R T _ P A R T _ S U R F _ A R E A
+ */
+void
+rt_part_surf_area(fastf_t *area, const struct rt_db_internal *ip)
+{
+ fastf_t vrad, hrad, mag_h;
+ struct rt_part_internal *pip = (struct rt_part_internal *)ip->idb_ptr;
+ RT_PART_CK_MAGIC(pip);
+
+ vrad = pip->part_vrad;
+ hrad = pip->part_hrad;
+ mag_h = MAGNITUDE(pip->part_H);
+
+ if (EQUAL(vrad, hrad)) {
+ *area = 2.0 * M_PI * vrad * (2.0 * vrad + mag_h);
+ } else {
+ fastf_t mid_section;
+ mid_section = M_PI * ((vrad + hrad) * sqrt((vrad - hrad) * (vrad -
hrad) + mag_h * mag_h));
+ *area = 2.0 * M_PI * (vrad * vrad + hrad * hrad) + mid_section;
+ }
+}
+
+
/*
* Local Variables:
* mode: C
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-comm...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel