[Jspro-cvs] jsPro README,1.23,1.24 math.js,1.23,1.24 CHANGES,1.18,1.19
Brought to you by:
wigleys
|
From: <wi...@us...> - 2003-09-24 13:10:29
|
Update of /cvsroot/jspro/jsPro
In directory sc8-pr-cvs1:/tmp/cvs-serv13382
Modified Files:
README math.js CHANGES
Log Message:
new methods: Math.approx(), Math.arg(), Math.exp10
Index: README
===================================================================
RCS file: /cvsroot/jspro/jsPro/README,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** README 19 Sep 2003 15:47:00 -0000 1.23
--- README 24 Sep 2003 13:10:23 -0000 1.24
***************
*** 103,203 ****
55. Math.acsc(): inverse cosecant
56. Math.acsch(): inverse hyperbolic cosecant
! 57. Math.asec(): inverse secant
! 58. Math.asech(): inverse hyperbolic secant
! 59. Math.asinh(): inverse hyperbolic sine
! 60. Math.atanh(): inverse hyperbolic tangent
! 61. Math.baseConvert(): convert base
! 62. Math.bin2dec(): binary to decimal conversion
! 63. Math.bin2hex(): binary to hexadecimal conversion
! 64. Math.bin2oct(): binary to octal conversion
! 65. Math.cosh(): hyperbolic cosine
! 66. Math.cot(): cotangent
! 67. Math.coth(): hyperbolic cotangent
! 68. Math.cov(): coversine
! 69. Math.csc(): cosecant
! 70. Math.csch(): hyperbolic cosecant
! 71. Math.dec2bin(): decimal to binary conversion
! 72. Math.dec2hex(): decimal to hexadecimal conversion
! 73. Math.dec2oct(): decimal to octal conversion
! 74. Math.deg2grad(): degree to gradian conversion
! 75. Math.deg2rad(): degree to radian conversion
! 76. Math.expm1(): exp(x) - 1
! 77. Math.exsec(): exsecant
! 78. Math.fibonacci(): Fibonacci sequence
! 79. Math.fmod(): floating-point remainder
! 80. Math.gd(): Gudermannian function
! 81. Math.grad2deg(): gradian to degree conversion
! 82. Math.grad2rad(): gradian to radian conversion
! 83. Math.hav(): haversine
! 84. Math.hex2bin(): hexadecimal to binary conversion
! 85. Math.hex2dec(): hexadecimal to decimal conversion
! 86. Math.hex2oct(): hexadecimal to octal conversion
! 87. Math.hypot(): hypotenuse
! 88. Math.isEven(): is even?
! 89. Math.isOdd(): is odd?
! 90. Math.isPrime(): is prime?
! 91. Math.log10(): base-10 logarithm
! 92. Math.log2(): base-2 logarithm
! 93. Math.log1p(): log(1 + x)
! 94. Math.luhn(): LUHN formula
! 95. Math.oct2bin(): octal to binary conversion
! 96. Math.oct2dec(): octal to decimal conversion
! 97. Math.oct2hex(): octal to hexadecimal conversion
! 98. Math.pi(): calculate pi
! 99. Math.rad2deg(): radian to degree conversion
! 100. Math.rad2grad(): radian to gradian conversion
! 101. Math.sec(): secant
! 102. Math.sech(): hyperbolic secant
! 103. Math.sigmoid(): sigmoid function
! 104. Math.sign(): sign
! 105. Math.sinc(): sinc function
! 106. Math.sinh(): hyperbolic sine
! 107. Math.sq(): square
! 108. Math.tanc(): tanc function
! 109. Math.tanh(): hyperbolic tangent
! 110. Math.vers(): versine
point.js
-------------------------------------------------------------------------------
! 111. Point.prototype.distance(): distance between two points
string.js
-------------------------------------------------------------------------------
! 112. String.prototype.addSlashes(): escape certain characters with backslashes
! 113. String.prototype.cat(): concatenate
! 114. String.prototype.compress(): compress to spaces
! 115. String.prototype.count(): count occurrence of characters
! 116. String.prototype.htmlEntities(): encode XHTML 1.0 entities
! 117. String.prototype.htmlSpecialChars(): encode subset of HTML special characters
! 118. String.prototype.insert(): insert a string
! 119. String.prototype.isEmailAddress(): is email address?
! 120. String.prototype.levenshtein(): Levenshtein distance
! 121. String.prototype.lpad(): pad left side
! 122. String.prototype.ltrim(): trim left side
! 123. String.prototype.nl2br(): newline to <br> conversion
! 124. String.prototype.overlay(): overlay a string
! 125. String.prototype.pad(): pad
! 126. String.prototype.remove(): delete characters
! 127. String.prototype.repeat(): repeat
! 128. String.prototype.repeatChars(): repeat characters
! 129. String.prototype.reverse(): reverse
! 130. String.prototype.rot13(): rotate 13 encoding
! 131. String.prototype.rpad(): pad right side
! 132. String.prototype.rtrim(): trim right side
! 133. String.prototype.swap(): swap characters
! 134. String.prototype.trim(): trim
! 135. String.prototype.truncate(): truncate
! 136. String.prototype.ucFirst(): uppercase first character
! 137. String.prototype.ucWords(): uppercase words
! 138. String.prototype.wordWrap(): word wrap
validator.js
-------------------------------------------------------------------------------
! 139. Validator.prototype.isBlankString(): is a blank string
! 140. Validator.prototype.isDigit(): is a single digit
! 141. Validator.prototype.isInteger(): is an integer
! This file was generated automatically: Fri Sep 19 16:48:38 2003
--- 103,206 ----
55. Math.acsc(): inverse cosecant
56. Math.acsch(): inverse hyperbolic cosecant
! 57. Math.approx(): approximately equal
! 58. Math.arg(): polar angle (argument)
! 59. Math.asec(): inverse secant
! 60. Math.asech(): inverse hyperbolic secant
! 61. Math.asinh(): inverse hyperbolic sine
! 62. Math.atanh(): inverse hyperbolic tangent
! 63. Math.baseConvert(): convert base
! 64. Math.bin2dec(): binary to decimal conversion
! 65. Math.bin2hex(): binary to hexadecimal conversion
! 66. Math.bin2oct(): binary to octal conversion
! 67. Math.cosh(): hyperbolic cosine
! 68. Math.cot(): cotangent
! 69. Math.coth(): hyperbolic cotangent
! 70. Math.cov(): coversine
! 71. Math.csc(): cosecant
! 72. Math.csch(): hyperbolic cosecant
! 73. Math.dec2bin(): decimal to binary conversion
! 74. Math.dec2hex(): decimal to hexadecimal conversion
! 75. Math.dec2oct(): decimal to octal conversion
! 76. Math.deg2grad(): degree to gradian conversion
! 77. Math.deg2rad(): degree to radian conversion
! 78. Math.exp10(): exponent of 10
! 79. Math.expm1(): exp(x) - 1
! 80. Math.exsec(): exsecant
! 81. Math.fibonacci(): Fibonacci sequence
! 82. Math.fmod(): floating-point remainder
! 83. Math.gd(): Gudermannian function
! 84. Math.grad2deg(): gradian to degree conversion
! 85. Math.grad2rad(): gradian to radian conversion
! 86. Math.hav(): haversine
! 87. Math.hex2bin(): hexadecimal to binary conversion
! 88. Math.hex2dec(): hexadecimal to decimal conversion
! 89. Math.hex2oct(): hexadecimal to octal conversion
! 90. Math.hypot(): hypotenuse
! 91. Math.isEven(): is even?
! 92. Math.isOdd(): is odd?
! 93. Math.isPrime(): is prime?
! 94. Math.log10(): base-10 logarithm
! 95. Math.log2(): base-2 logarithm
! 96. Math.log1p(): log(1 + x)
! 97. Math.luhn(): LUHN formula
! 98. Math.oct2bin(): octal to binary conversion
! 99. Math.oct2dec(): octal to decimal conversion
! 100. Math.oct2hex(): octal to hexadecimal conversion
! 101. Math.pi(): calculate pi
! 102. Math.rad2deg(): radian to degree conversion
! 103. Math.rad2grad(): radian to gradian conversion
! 104. Math.sec(): secant
! 105. Math.sech(): hyperbolic secant
! 106. Math.sigmoid(): sigmoid function
! 107. Math.sign(): sign
! 108. Math.sinc(): sinc function
! 109. Math.sinh(): hyperbolic sine
! 110. Math.sq(): square
! 111. Math.tanc(): tanc function
! 112. Math.tanh(): hyperbolic tangent
! 113. Math.vers(): versine
point.js
-------------------------------------------------------------------------------
! 114. Point.prototype.distance(): distance between two points
string.js
-------------------------------------------------------------------------------
! 115. String.prototype.addSlashes(): escape certain characters with backslashes
! 116. String.prototype.cat(): concatenate
! 117. String.prototype.compress(): compress whitespace to single spaces
! 118. String.prototype.count(): count occurrence of characters
! 119. String.prototype.htmlEntities(): encode XHTML 1.0 entities
! 120. String.prototype.htmlSpecialChars(): encode subset of HTML special characters
! 121. String.prototype.insert(): insert one string into another
! 122. String.prototype.isEmailAddress(): is email address?
! 123. String.prototype.levenshtein(): Levenshtein distance
! 124. String.prototype.lpad(): pad left side
! 125. String.prototype.ltrim(): trim left side
! 126. String.prototype.nl2br(): newline to <br> conversion
! 127. String.prototype.overlay(): overlay one string over another
! 128. String.prototype.pad(): pad
! 129. String.prototype.remove(): remove characters
! 130. String.prototype.repeat(): repeat
! 131. String.prototype.repeatChars(): repeat characters
! 132. String.prototype.reverse(): reverse
! 133. String.prototype.rot13(): rotate 13 encoding
! 134. String.prototype.rpad(): pad right side
! 135. String.prototype.rtrim(): trim right side
! 136. String.prototype.swap(): swap characters
! 137. String.prototype.trim(): trim
! 138. String.prototype.truncate(): truncate
! 139. String.prototype.ucFirst(): uppercase first character
! 140. String.prototype.ucWords(): uppercase words
! 141. String.prototype.wordWrap(): word wrap
validator.js
-------------------------------------------------------------------------------
! 142. Validator.prototype.isBlankString(): is blank string?
! 143. Validator.prototype.isDigit(): is single digit?
! 144. Validator.prototype.isInteger(): is integer?
! This file was generated automatically: Wed Sep 24 14:11:37 2003
Index: math.js
===================================================================
RCS file: /cvsroot/jspro/jsPro/math.js,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** math.js 22 Sep 2003 06:56:07 -0000 1.23
--- math.js 24 Sep 2003 13:10:23 -0000 1.24
***************
*** 257,260 ****
--- 257,378 ----
/**
+ * Calculates if two numbers are approximately equal. Approximation defaults
+ * to +/- 0.01 but can be optionally set using the <code>fEpsilon</code>
+ * argument
+ *
+ * @summary approximately equal
+ * @author Stuart Wigley
+ * @version 1.0, 09/24/03
+ * @interface <code>Math.approx(fX, fY)</code>
+ * @interface <code>Math.approx(fX, fY, fEpsilon)</code>
+ * @param fX a floating-point number
+ * @param fY a floating-point number
+ * @param fEpsilon accuracy of approximation (optional)
+ * @return true if <code>fX</code> and <code>fY</code> are
+ * approximately equal; false otherwise
+ * @return <code>null</code> if an exception is encountered
+ * @throws IllegalArgumentException
+ * @throws TypeMismatchException
+ */
+ Math.approx = function() {
+
+ try {
+
+ var vError = null;
+ var iNumArguments = arguments.length;
+ var fX, fY;
+ var fEpsilon = 0.01;
+
+ if (iNumArguments == 2) {
+ fX = arguments[0];
+ fY = arguments[1];
+ } else if (iNumArguments == 3) {
+ fX = arguments[0];
+ fY = arguments[1];
+ fEpsilon = arguments[2];
+ } else {
+ throw vError = new IllegalArgumentException('Math.approx', '2 or 3', iNumArguments);
+ }
+
+ if (typeof fX != 'number') {
+ throw vError = new TypeMismatchException('Math.approx', 'number', typeof fX);
+ }
+ if (typeof fY != 'number') {
+ throw vError = new TypeMismatchException('Math.approx', 'number', typeof fY);
+ }
+ if (typeof fEpsilon != 'number') {
+ throw vError = new TypeMismatchException('Math.approx', 'number', typeof fEpsilon);
+ }
+
+ var bApprox = (Math.abs(fX - fY) < fEpsilon) ? true : false;
+ }
+ catch (vError) {
+
+ if (vError instanceof Error) {
+ vError.handleError();
+ }
+ }
+ finally {
+
+ return vError ? null : bApprox;
+ }
+ }
+
+
+ /**
+ * Calculates the polar angle (argument) of a pair of rectangular coordinates.
+ *
+ * @summary polar angle (argument)
+ * @author Stuart Wigley
+ * @version 1.0, 09/24/03
+ * @interface <code>Math.arg(fX, fY)</code>
+ * @requires <code>math.sign()</code>
+ * @param fX a floating-point number
+ * @param fY a floating-point number
+ * @return the polar angle (argument)
+ * @return <code>null</code> if an exception is encountered
+ * @throws IllegalArgumentException
+ * @throws TypeMismatchException
+ * @throws MethodNotAvailableException
+ * @see <code>math.sign()</code>
+ */
+ Math.arg = function(fX, fY) {
+
+ try {
+
+ var vError = null;
+ var iNumArguments = arguments.length;
+
+ if (!('sign' in this)) {
+ throw vError = new MethodNotAvailableException('Math.arg', 'Math.sign');
+ }
+
+ if (iNumArguments != 2) {
+ throw vError = new IllegalArgumentException('Math.arg', 2, iNumArguments);
+ }
+
+ if (typeof fX != 'number') {
+ throw vError = new TypeMismatchException('Math.arg', 'number', typeof fX);
+ }
+ if (typeof fY != 'number') {
+ throw vError = new TypeMismatchException('Math.arg', 'number', typeof fY);
+ }
+
+ var fArgument = Math.atan2(fY, fX) + (Math.PI / 2) * Math.sign(fY) * (1 - Math.sign(fX));
+ }
+ catch (vError) {
+
+ if (vError instanceof Error) {
+ vError.handleError();
+ }
+ }
+ finally {
+
+ return vError ? null : fArgument;
+ }
+ }
+
+
+ /**
* Calculates and returns the inverse secant of a number in 2D Cartesian
* space.
***************
*** 1129,1132 ****
--- 1247,1293 ----
return vError ? null : fRadians;
+ }
+ }
+
+
+ /**
+ * Calculates the exponent of 10. ie 10 to the power of <code>fX</code>
+ *
+ * @summary exponent of 10
+ * @author Stuart Wigley
+ * @version 1.0, 09/24/03
+ * @interface <code>Math.exp10(fX)</code>
+ * @param fX a floating-point number
+ * @return 10 raised to the power of <code>fX</code>
+ * @return <code>null</code> if an exception is encountered
+ * @throws IllegalArgumentException
+ * @throws TypeMismatchException
+ */
+ Math.exp10 = function(fX) {
+
+ try {
+
+ var vError = null;
+ var iNumArguments = arguments.length;
+
+ if (iNumArguments != 1) {
+ throw vError = new IllegalArgumentException('Math.exp10', 1, iNumArguments);
+ }
+
+ if (typeof fX != 'number') {
+ throw vError = new TypeMismatchException('Math.exp10', 'number', typeof fX);
+ }
+
+ var fExponent10 = Math.pow(10, fX);
+ }
+ catch (vError) {
+
+ if (vError instanceof Error) {
+ vError.handleError();
+ }
+ }
+ finally {
+
+ return vError ? null : fExponent10;
}
}
Index: CHANGES
===================================================================
RCS file: /cvsroot/jspro/jsPro/CHANGES,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** CHANGES 22 Sep 2003 08:00:59 -0000 1.18
--- CHANGES 24 Sep 2003 13:10:23 -0000 1.19
***************
*** 39,43 ****
--- 39,46 ----
math.js:
+ - Math.approx()
+ - Math.arg()
- Math.baseConvert()
+ - Math.exp10()
- Math.fmod()
- Math.pi()
|