This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
I've been doing some work recently with geographic/spatial data sets and SVG. XSLT and XQuery are ideal for manipulating this kind of data but have one serious shortcoming - the lack of some basic functions needed for geometrical calculations. I would therefore like to propose the addition of four functions: sqrt(), sin(), cos() and tan(), all defined with the signature X(xs:double?) -> xs:double?. I don't think that providing these will be a major burden on implementors since they are so widely implemented in standard libraries and the specification is unproblematic. I know this isn't on the requirements list but I think there's a real user need and the benefit is worth the effort.
I'd second this. Presumably the arguments would be in radians for the trig. functions? Wouldn't it make sense to have inverse functions too?
We have implemented a bunch of maths functions (documented at http://www.xqsharp.com/xqsharp/functions.htm). When we came to implement the sin/cos functions using the Microsoft .NET implementations, we were surprised by the behaviour on large inputs: "For values of $arg outside the range from approximately -9223372036854775295 to approximately 9223372036854775295, the fn:cos function returns $arg unchanged." as a result of the behaviour of Math.Sin documented at http://msdn.microsoft.com/en-us/library/system.math.sin.aspx which we presume is due to the behaviour of the C function documented at http://msdn.microsoft.com/en-us/library/aa272931(VS.60).aspx There is further information relating to the Java platform at http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Math.html and http://java.sun.com/j2se/1.5.0/docs/api/java/lang/StrictMath.html which offers two implementations (StrictMath.Sin and Math.Sin). I mention this because it may need to be considered when deciding what results might be considered as conformant for a particular function.
Equally as important as sin(x) and cos(x) is atan2(y,x). Just as sin and cos are useful for converting polar coordinates to rectangular coordinates, atan2 is essential for converting rectangular coordinates to polar. With atan2 and sqrt, computing other inverse trigonometric functions is easy, just as it is easy to compute tan given implementations for sin and cos.
Yes, I agree with comment #3
The WGs agreed in principle, at its F2F meeting during the week of 2009-03-23, to add a number of such functions. I'm marking this bug ACCEPTED, and it will be marked RESOLVED/FIXED when the details have been made more public (e.g., in a public Working Draft).
Despite Jim's statement in comment #5, I am following the convention we have used for other bugs: it is Fixed/Resolved when a decision is made, and Closed when the editor's draft has been updated. I am therefore marking this fixed and closed.