Revision: 44867
http://brlcad.svn.sourceforge.net/brlcad/?rev=44867&view=rev
Author: brlcad
Date: 2011-06-09 12:31:50 +0000 (Thu, 09 Jun 2011)
Log Message:
-----------
consolidate and move rt_ell_ang() from epa.c to ell.c since it's used by ehy,
epa, and hyp. Add to librt_private.h since it's private reuse API.
Modified Paths:
--------------
brlcad/trunk/src/librt/librt_private.h
brlcad/trunk/src/librt/primitives/ell/ell.c
brlcad/trunk/src/librt/primitives/epa/epa.c
Modified: brlcad/trunk/src/librt/librt_private.h
===================================================================
--- brlcad/trunk/src/librt/librt_private.h 2011-06-09 12:13:09 UTC (rev
44866)
+++ brlcad/trunk/src/librt/librt_private.h 2011-06-09 12:31:50 UTC (rev
44867)
@@ -64,6 +64,14 @@
extern void flip_dbmat_mat(dbfloat_t *dbp, const fastf_t *ff);
+/**
+ * return angle required for smallest side to fall within tolerances
+ * for ellipse. Smallest side is a side with an endpoint at (a, 0, 0)
+ * where a is the semi-major axis.
+ */
+extern fastf_t rt_ell_ang(fastf_t *p1, fastf_t a, fastf_t b, fastf_t dtol,
fastf_t ntol);
+
+
__END_DECLS
/*
Modified: brlcad/trunk/src/librt/primitives/ell/ell.c
===================================================================
--- brlcad/trunk/src/librt/primitives/ell/ell.c 2011-06-09 12:13:09 UTC (rev
44866)
+++ brlcad/trunk/src/librt/primitives/ell/ell.c 2011-06-09 12:31:50 UTC (rev
44867)
@@ -1676,6 +1676,45 @@
}
+/*
+ * Used by EHY, EPA, HYP. See librt_private.h for details.
+ */
+fastf_t
+rt_ell_ang(fastf_t *p1, fastf_t a, fastf_t b, fastf_t dtol, fastf_t ntol)
+{
+ fastf_t dist, intr, m, theta0, theta1;
+ point_t mpt, p0;
+ vect_t norm_line, norm_ell;
+
+ VSET(p0, a, 0., 0.);
+ /* slope and intercept of segment */
+ m = (p1[Y] - p0[Y]) / (p1[X] - p0[X]);
+ intr = p0[Y] - m * p0[X];
+ /* point on ellipse with max dist between ellipse and line */
+ mpt[X] = a / sqrt(b*b / (m*m*a*a) + 1);
+ mpt[Y] = b * sqrt(1 - mpt[X] * mpt[X] / (a*a));
+ mpt[Z] = 0;
+ /* max distance between that point and line */
+ dist = fabs(m * mpt[X] - mpt[Y] + intr) / sqrt(m * m + 1);
+ /* angles between normal of line and of ellipse at line endpoints */
+ VSET(norm_line, m, -1., 0.);
+ VSET(norm_ell, b * b * p0[X], a * a * p0[Y], 0.);
+ VUNITIZE(norm_line);
+ VUNITIZE(norm_ell);
+ theta0 = fabs(acos(VDOT(norm_line, norm_ell)));
+ VSET(norm_ell, b * b * p1[X], a * a * p1[Y], 0.);
+ VUNITIZE(norm_ell);
+ theta1 = fabs(acos(VDOT(norm_line, norm_ell)));
+ /* split segment at widest point if not within error tolerances */
+ if (dist > dtol || theta0 > ntol || theta1 > ntol) {
+ /* split segment */
+ return rt_ell_ang(mpt, a, b, dtol, ntol);
+ } else
+ return(acos(VDOT(p0, p1)
+ / (MAGNITUDE(p0) * MAGNITUDE(p1))));
+}
+
+
/** @} */
/*
* Local Variables:
Modified: brlcad/trunk/src/librt/primitives/epa/epa.c
===================================================================
--- brlcad/trunk/src/librt/primitives/epa/epa.c 2011-06-09 12:13:09 UTC (rev
44866)
+++ brlcad/trunk/src/librt/primitives/epa/epa.c 2011-06-09 12:31:50 UTC (rev
44867)
@@ -933,49 +933,6 @@
/**
- * R T _ E L L _ A N G
- *
- * Return angle required for smallest side to fall within tolerances
- * for ellipse. Smallest side is a side with an endpoint at (a, 0, 0)
- * where a is the semi-major axis.
- */
-fastf_t
-rt_ell_ang(fastf_t *p1, fastf_t a, fastf_t b, fastf_t dtol, fastf_t ntol)
-{
- fastf_t dist, intr, m, theta0, theta1;
- point_t mpt, p0;
- vect_t norm_line, norm_ell;
-
- VSET(p0, a, 0., 0.);
- /* slope and intercept of segment */
- m = (p1[Y] - p0[Y]) / (p1[X] - p0[X]);
- intr = p0[Y] - m * p0[X];
- /* point on ellipse with max dist between ellipse and line */
- mpt[X] = a / sqrt(b*b / (m*m*a*a) + 1);
- mpt[Y] = b * sqrt(1 - mpt[X] * mpt[X] / (a*a));
- mpt[Z] = 0;
- /* max distance between that point and line */
- dist = fabs(m * mpt[X] - mpt[Y] + intr) / sqrt(m * m + 1);
- /* angles between normal of line and of ellipse at line endpoints */
- VSET(norm_line, m, -1., 0.);
- VSET(norm_ell, b * b * p0[X], a * a * p0[Y], 0.);
- VUNITIZE(norm_line);
- VUNITIZE(norm_ell);
- theta0 = fabs(acos(VDOT(norm_line, norm_ell)));
- VSET(norm_ell, b * b * p1[X], a * a * p1[Y], 0.);
- VUNITIZE(norm_ell);
- theta1 = fabs(acos(VDOT(norm_line, norm_ell)));
- /* split segment at widest point if not within error tolerances */
- if (dist > dtol || theta0 > ntol || theta1 > ntol) {
- /* split segment */
- return rt_ell_ang(mpt, a, b, dtol, ntol);
- } else
- return(acos(VDOT(p0, p1)
- / (MAGNITUDE(p0) * MAGNITUDE(p1))));
-}
-
-
-/**
* R T _ E P A _ T E S S
*
* Returns -
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits