It is not necessary at all to use any extension functions.
Use the FXSL function f:arctan(), which is written completely in XSLT.
Here is an example:
When this transformation is applied on any xml document (ignored):
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:f="http://fxsl.sf.net/"
<xsl:import href="../f/func-arcTrignm.xsl" />
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="1 to 10">
<xsl:value-of select="f:arctan(1 div ., 0.000001, 'deg')"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
the result is:
45.000000000560625
26.565053176898004
18.434948193902347
14.036242861145283
11.309932383859845
9.462322136978774
8.130102294470776
7.125016296527626
6.340191698516003
5.710593093647205
I can see when calculating 1000 different values of f:arctan(), that
it takes arround 5 milliseconds per single calculation (and this
includes the time to output the 1000-line result)
--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
On Wed, Mar 19, 2008 at 7:18 AM, Patrick Bergeron
<pbergeron(_at_)innobec(_dot_)com> wrote:
Hello,
I'm trying to make a small template that concisely implements atan2, but
returns the values in degrees and handles the case where DX is zero. So
far, I have:
<xsl:template name="my_atan2">
<xsl:param name="dx" />
<xsl:param name="dy" />
<xsl:variable name="rad" >
<xsl:choose>
<xsl:when test="dx != 0">
<xsl:value-of select="exsl:atan2(dx,
dy)" />
</xsl:when>
<xsl:when test="(dx = 0) and (dy > 0)">
<xsl:value-of select="$my_pi" />
</xsl:when>
<xsl:when test="(dx = 0) and (dy < 0)">
<xsl:value-of select="$my_pi * 3" />
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$rad < 0">
<xsl:value-of select="($rad * 180 div
$my_pi) + 360" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="($rad * 180 div
$my_pi)" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Is there a way to express this in only a few lines without all the
verbosity?
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--