Commit Graph

104 Commits

Author SHA1 Message Date
Michael Bayne c99825d35f Logic simplification in iceil/ifloor. 2012-05-11 08:33:53 -07:00
David Hoover e8c11aba87 Nix unused locals in matrix operations.
Compilers are presumably smart enough to throw away the bulk of that
automagically, but some were storing the return value of a method call
of some object that implemented an interface whic his a lot harder for
it to realize won't have side effects.
2012-05-10 22:08:35 -07:00
David Hoover 6d920c1211 Don't describe a particular implementation's details in the interface declaration. 2012-05-10 22:03:05 -07:00
David Hoover be0d761aa2 Mark @Overrides. 2012-05-10 22:03:05 -07:00
David Hoover 0a03eb6849 Whitespace & doc cleanup.
Tabs -> spaces, one space between sentences, capitalization fix, etc.
2012-05-10 22:02:37 -07:00
Michael Bayne 8bcd5c25c8 Be more flexible about the type of our target transform. 2012-05-03 08:56:35 -07:00
Michael Bayne 0daba7bc49 Added Vector.subtractLocal(x, y). 2012-05-01 09:54:31 -07:00
Michael Bayne 8524f5c911 Updated double versions. 2012-04-30 15:15:01 -07:00
Michael Bayne b7c2d6f420 Added Vector.subtract that takes individual components.
Closes #11.
2012-04-30 15:14:44 -07:00
Michael Bayne 7048d8231b Added Vector.cross() & co.
Closes #10.
2012-04-30 15:07:44 -07:00
Michael Bayne 1eeb1ee73a Fixed some isNaNs. 2012-04-30 11:33:30 -07:00
Michael Bayne a8c8c748bd Fixed some epsilons. 2012-04-30 11:31:55 -07:00
Michael Bayne 4c9a82979d Updated double versions of things. 2012-04-30 11:29:45 -07:00
Michael Bayne c8e4cbeca0 Added Transform.transformPoint(Vector), enabled Ray2 transforms.
I've tried to make a useful distinction between Point and Vector, but sometimes
you just want to use a Vector as a Point. I'm not going to add Point3 and try
to push this distinction into the third dimension, so I'll accommodate using
Vector as Point in 2D, and we'll just use Vector3 as a 3D point when needed.
2012-04-30 11:26:18 -07:00
Michael Bayne f8cce64528 Added Ray2 and Ray3. 2012-04-30 11:19:51 -07:00
Michael Bayne 17b19fe21b Added numerous 3D geometry classes; unabstracted Vector3, Matrix3. 2012-04-29 19:51:38 -07:00
Michael Bayne da49fe5362 Whitespace trimski! 2012-04-24 13:08:01 -07:00
Michael Bayne 0f9cc66388 Matrix3 and Vector3 for your three dimensional pleasures. 2012-04-24 10:23:39 -07:00
Michael Bayne cb8de43027 Manage our branches explicitly in clamp.
This provides saner behavior when clamping to "nonsense" ranges like [5, 3].
2012-04-03 15:30:18 -07:00
Michael Bayne c9c336309b Tidied javadocs, generated double implementation. 2011-12-20 19:09:19 -08:00
Tim Conkling d2bebff736 Functions for computing the distance between a Point and a Rectangle 2011-12-16 12:35:25 -08:00
Michael Bayne 060ff1b877 Make the upper bound exclusive in normalizeAngle(Positive). 2011-11-22 16:43:52 -08:00
Michael Bayne 274dd1858d Fix typo. Thanks Tim! 2011-11-19 16:45:25 -08:00
Michael Bayne cc5e599235 Match the argument ordering of the float version. 2011-11-16 13:56:33 -08:00
Michael Bayne 26cf80f38f Added an integer MathUtil with clamp(low, value, high). 2011-11-16 13:55:34 -08:00
Michael Bayne 403bafce13 Ray recommends using <= when comparing to epsilon.
This allows epsilon of 0 to work.
2011-10-11 13:17:05 -07:00
Michael Bayne b67c0bfc48 Added IVector.isZero(), Vectors.isZero(), isEpsilonZero(), isEpsilonEquals(),
and similar epsilon equals methods to Points.
2011-10-11 12:43:50 -07:00
Michael Bayne 2a1e86e77f Formatting. 2011-10-11 12:43:35 -07:00
Charlie Groves b54f684f45 Allow MathUtil.toString's decimals to be specified 2011-10-05 15:07:53 -07:00
Michael Bayne 5e344f9511 Avoid an extra division (and field update) in setScaleX/Y. Thanks Tim! 2011-09-15 16:24:29 -07:00
Michael Bayne c6321e4573 Version of circle code specialized on double. 2011-09-09 10:08:49 -07:00
Michael Bayne 2753a9523d Small tidying. 2011-09-09 10:07:34 -07:00
Tim Conkling c82f38fa97 It helps to get the math right 2011-09-09 10:05:11 -07:00
Tim Conkling 1916a7e8e7 Circle implementation 2011-09-09 10:05:02 -07:00
Michael Bayne 42d4353788 Various Vector enhancements.
- Moved Vector.direction to Point.direction as that makes more sense. If you
  want to know the angle of the vector between two points, you should do that
  on points, not vectors.

- Added Vector.angle() which returns the angle of the vector (in polar
  coordinates), which matches Vector.length() which returns the magnitude of
  the vector (in polar coordinates).

- Added Vectors.fromPolar to create a vector from polar coordinates, and added
  Vector.setLength and Vector.setAngle to set the one whilst preserving the
  other.
2011-09-02 15:55:05 -07:00
Michael Bayne 49eafa5653 Vector.angle -> Vector.angleBetween. 2011-09-02 15:23:13 -07:00
Michael Bayne 0644fc6f59 Added Point.subtract, for creating a vector from endpoints. 2011-09-02 15:21:17 -07:00
Michael Bayne ffd2f10b24 Changed Vector.mult to Vector.scale and clarified the javadocs.
As Tim points out, vector multiplication implies dot or cross products. These
methods are scaling, not multiplying. Cross product coming in a future commit.
2011-09-02 15:15:06 -07:00
Michael Bayne cc1c1d3f51 Use super-source to provide our GWT-specialized Platform.java. 2011-08-13 09:32:34 -07:00
Michael Bayne c8d591c8a2 Converted the float bits to double since they've substantially evolved. 2011-08-12 11:00:36 -07:00
Michael Bayne 0d82811da9 Split FloatMath into MathUtil and FloatMath.
FloatMath contains only shim methods that convert double Math methods to float,
but extends MathUtil so that library users can easily access everything via one
class. MathUtil is used internally so that I can convert pythagoras.f to
pythagoras.d with a few sed expressions. And MathUtil would be what users of
pythagoras.d would want to use for their lerping, clamping and stringifying.
2011-08-12 10:57:53 -07:00
Michael Bayne 41f62de088 getX -> x (in both the literal and algebraic sense).
In anticipation of the saying of nay, I offer this: these are value classes,
and in a civilized language, I wouldn't have setters either. "foo.x = x" would
call a setter method over which I had control. However, rather than throwing my
hands up and saying "Gee, I have to have verbose setters, so I guess I better
have verbose getters," I say, "I'll take what I can get."

Methods that verb can be verbs, and we can all agree to understand that methods
that are nouns are getters. foo.width() does not width my foo, it's my foo's
width. foo.invert() inverts up my foo, it is not some attribute of my foo's
nonsensically named invert. I don't want to add my foo's getWidth and
getHeight, I want to add my foo's width and height. So why should I have to
type get over and over again just because I want to protect myself from future
representation change? (Or in this case, to offer immutable views of my value
classes.)
2011-08-12 10:19:37 -07:00
Michael Bayne a537b6627d Fixed typo. 2011-08-05 16:47:39 -07:00
Michael Bayne 5e7529d969 Fixed bug in getTy(). 2011-08-05 16:45:49 -07:00
Michael Bayne e7cfc6c350 Fixed translate() methods. 2011-08-05 16:45:32 -07:00
Michael Bayne e21872e686 GLSL uses column-major matrices, so let's use those as well to avoid confusing
mismatch.
2011-08-05 13:56:13 -07:00
Michael Bayne 1936e20380 Fixed FloatMath.toString(), added tests. 2011-07-29 11:00:20 -07:00
Michael Bayne 102fb340b7 Improved float value formatting. 2011-07-19 09:33:17 -07:00
Michael Bayne d3b91156b0 Removed IEEERemainder for GWT compatibility. 2011-07-12 07:27:02 -07:00
Michael Bayne e90f70a0f6 Implemented affine inverse transforms without creating an intermediate inverted
transform.
2011-07-11 14:41:34 -07:00