summaryrefslogtreecommitdiff
path: root/nuttx/graphics/nxglib/nxglib_splitline.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-08-25 03:13:28 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-08-25 03:13:28 +0000
commitdd1ef395973e4ab66fea26c543856e7c29e794cf (patch)
tree9ef724295feb6465ad892d4334bdc0376f30ace5 /nuttx/graphics/nxglib/nxglib_splitline.c
parent67d6e613acb5129a2ca4a66ddf9cc6577933bc37 (diff)
downloadpx4-nuttx-dd1ef395973e4ab66fea26c543856e7c29e794cf.tar.gz
px4-nuttx-dd1ef395973e4ab66fea26c543856e7c29e794cf.tar.bz2
px4-nuttx-dd1ef395973e4ab66fea26c543856e7c29e794cf.zip
Fix nxgl_splitline bug
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3912 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics/nxglib/nxglib_splitline.c')
-rw-r--r--nuttx/graphics/nxglib/nxglib_splitline.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/nuttx/graphics/nxglib/nxglib_splitline.c b/nuttx/graphics/nxglib/nxglib_splitline.c
index 5bace1448..eff516db3 100644
--- a/nuttx/graphics/nxglib/nxglib_splitline.c
+++ b/nuttx/graphics/nxglib/nxglib_splitline.c
@@ -48,6 +48,8 @@
* Pre-Processor Definitions
****************************************************************************/
+#define SMALL_SIN 1966 /* 1966/65536 = 0.03 */
+
/****************************************************************************
* Private Types
****************************************************************************/
@@ -231,14 +233,14 @@ int nxgl_splitline(FAR struct nxgl_vector_s *vector,
/* If the sine of the angle is tiny (i.e., the line is nearly horizontal),
* then we cannot compute the adjusted width. In this case, just use
- * the width of the line (not very good estimate -- need to revisit).
+ * the width of the line bounding box.
*/
sinangle = b16sin(angle);
- if (sinangle == 0)
+ if (sinangle < SMALL_SIN)
{
adjwidth = itob16(iwidth);
- xoffset = adjwidth;
+ xoffset = 0;
}
else
{
@@ -246,6 +248,7 @@ int nxgl_splitline(FAR struct nxgl_vector_s *vector,
xoffset = itob16(linewidth * linewidth);
xoffset = b16divb16(xoffset, adjwidth);
}
+
halfoffset = (xoffset >> 1);
/* Return the top triangle (if there is one). NOTE that the horizontal