Subject: [xsl] XSLT verbosity (atan2) From: "Patrick Bergeron" <pbergeron@xxxxxxxxxxx> Date: Wed, 19 Mar 2008 10:18:14 -0400 |
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?
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Looping through multiple , David Carlisle | Thread | Re: [xsl] XSLT verbosity (atan2), David Carlisle |
Re: [xsl] push-pull, David Carlisle | Date | Re: [xsl] XSLT verbosity (atan2), David Carlisle |
Month |