Revision: 53736
http://brlcad.svn.sourceforge.net/brlcad/?rev=53736&view=rev
Author: n_reed
Date: 2012-11-16 20:38:02 +0000 (Fri, 16 Nov 2012)
Log Message:
-----------
make arc drawing logic clearer
Modified Paths:
--------------
brlcad/trunk/src/librt/primitives/pipe/pipe.c
Modified: brlcad/trunk/src/librt/primitives/pipe/pipe.c
===================================================================
--- brlcad/trunk/src/librt/primitives/pipe/pipe.c 2012-11-16 19:57:32 UTC
(rev 53735)
+++ brlcad/trunk/src/librt/primitives/pipe/pipe.c 2012-11-16 20:38:02 UTC
(rev 53736)
@@ -1697,34 +1697,31 @@
fastf_t *end,
int seg_count)
{
- fastf_t arc_angle;
- fastf_t delta_ang;
- fastf_t cos_del, sin_del;
- fastf_t x, y, xnew, ynew;
- vect_t to_end;
- point_t pt;
int i;
+ point_t pt;
+ vect_t center_to_start, center_to_end, axis_a, axis_b;
+ fastf_t radians_from_start_to_end, radian, radian_step;
BU_CK_LIST_HEAD(vhead);
- VSUB2(to_end, end, center);
- arc_angle = atan2(VDOT(to_end, v2), VDOT(to_end, v1));
- delta_ang = arc_angle / seg_count;
+ VSCALE(axis_a, v1, radius);
+ VSCALE(axis_b, v2, radius);
+ VMOVE(center_to_start, v1);
+ VSUB2(center_to_end, end, center);
+ VUNITIZE(center_to_end);
- cos_del = cos(delta_ang);
- sin_del = sin(delta_ang);
+ radians_from_start_to_end = acos(VDOT(center_to_start, center_to_end));
+ radian_step = radians_from_start_to_end / seg_count;
- x = radius;
- y = 0.0;
- VJOIN2(pt, center, x, v1, y, v2);
+ ellipse_point_at_radian(pt, center, axis_a, axis_b, 0.0);
RT_ADD_VLIST(vhead, pt, BN_VLIST_LINE_MOVE);
- for (i = 0; i < seg_count; i++) {
- xnew = x * cos_del - y * sin_del;
- ynew = x * sin_del + y * cos_del;
- VJOIN2(pt, center, xnew, v1, ynew, v2);
+
+ radian = radian_step;
+ for (i = 0; i < seg_count; ++i) {
+ ellipse_point_at_radian(pt, center, axis_a, axis_b, radian);
RT_ADD_VLIST(vhead, pt, BN_VLIST_LINE_DRAW);
- x = xnew;
- y = ynew;
+
+ radian += radian_step;
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits