Commit Graph

50 Commits

Author SHA1 Message Date
faiface 7c5e5588e2 fix Vec.Normal to rotate by pi/2, not -pi/2 2017-08-29 20:23:32 +02:00
Alex 3e3a9aaa48 fix operation order for rectangle resize function, add tests 2017-07-29 00:40:06 +12:00
faiface e64d97efb1 fix Rect.Intersect 2017-07-05 20:36:25 +02:00
faiface da52aa25ec clarify Rect.Intersect doc 2017-07-05 19:58:09 +02:00
faiface 69d4a37e5e add Rect.Intersect 2017-07-05 19:54:30 +02:00
faiface 2b9b4d07c4 add Rect.Area 2017-07-05 19:54:18 +02:00
faiface 886e7fa22a another minor code style change 2017-06-11 14:14:02 +02:00
faiface 99a43ec1a9 minor code style change 2017-06-11 14:06:45 +02:00
faiface d4cd1c33e2 one more tiny doc change 2017-06-11 01:18:23 +02:00
faiface 51cd0314d5 minor doc changes 2017-06-11 01:17:37 +02:00
Seebs daedc45ea9 Improve normal calculations
Soooo. It turns out that the bunch of smallish (~4-5% of runtime)
loads associated with Len(), Unit(), Rotated(), and so on... Were
actually more like 15% or more of computational effort. I first
figured this out by creating:

	func (u Vec) Normal(v Vec) Vec

which gives you a vector normal to u->v. That consumed a lot
of CPU time, and was followed by .Unit().Scaled(imd.thickness / 2),
which consumed a bit more CPU time.

After some poking, and in the interests of avoiding UI cruft,
the final selection is
	func (u Vec) Normal() Vec

This returns the vector rotated 90 degrees, which turns out to
be the most common problem.
2017-06-10 17:55:16 -05:00
faiface c0766504e3 minor, mostly stylistic, changes 2017-06-09 18:13:05 +02:00
Seebs c321515d3c Simplify Matrix math, use 6-value affine matrixes.
It turns out that affine matrices are much simpler than the 3x3 matrices
they imply, and we can use this to dramatically streamline some code.
For a test program, this was about a 50% gain in frame rate just from
the cost of the applyMatrixAndMask calls in imdraw, which were calling
matrix.Project() many times. Simplifying matrix.Project, alone, got a
nearly 50% frame rate boost!

Also modify pixelgl's SetMatrix to copy the six values of a 3x2
Affine into the corresponding locations of a 3x3 matrix.
2017-06-09 10:37:43 -05:00
faiface b8a287a654 clarify Rect doc 2017-05-21 19:38:21 +02:00
faiface 523e6d3e9a fix Matrix doc 2017-05-21 19:30:29 +02:00
faiface fcfeb200b6 replace complex128 Vec with a struct 2017-05-21 19:25:06 +02:00
faiface fdddde2780 accept zero target size in Rect.Resized 2017-05-15 01:15:16 +02:00
faiface 1619373062 add Rect.Union 2017-05-05 15:43:24 +02:00
faiface 8030595373 simplify code in Rect.Resized 2017-04-13 15:26:48 +02:00
faiface 9472b91565 fix grammar in Vec doc 2017-04-13 15:18:13 +02:00
faiface b41e117ac6 fix Matrix.String 2017-04-04 14:10:39 +02:00
faiface 49338251d2 add Matrix.String 2017-04-04 14:08:37 +02:00
faiface b135012115 minor change 2017-04-04 14:02:39 +02:00
faiface 5d98f28ca0 remove auto norm from R (Rect constructor) 2017-03-25 19:45:11 +01:00
faiface 4bebc7e6e4 add Vec.WithX/WithY and Rect.WithMin/WithMax 2017-03-23 19:27:39 +01:00
faiface 4619398b9e fix 0 vector len + fix imdraw polyline 2017-03-23 19:15:06 +01:00
faiface bec6bdca6a add Matrix.Chained 2017-03-19 00:08:46 +01:00
faiface 2e8f5fb05a remove Vec.YX because it's unreadable 2017-03-18 11:55:01 +01:00
faiface 31d4f08173 add Vec.YX 2017-03-18 11:34:31 +01:00
faiface 1f6d186539 fix another two misspells 2017-03-16 00:47:50 +01:00
faiface 6df99cdb35 fix many bugs in doc 2017-03-15 19:40:39 +01:00
faiface 7d1f685d4b clarify doc 2017-03-15 00:15:02 +01:00
faiface a614c3020c fix doc 2017-03-14 23:01:24 +01:00
faiface da0eb85c4b fix doc 2017-03-14 23:01:08 +01:00
faiface c81dedd9a1 add Rect.Size 2017-03-14 18:25:39 +01:00
faiface be276888f6 fix doc 2017-03-14 16:19:58 +01:00
faiface b3e5e9f902 consistently rename Matrix.Move -> Moved 2017-03-14 13:35:24 +01:00
faiface a2b9bb5b5a add X and Y vector constructors 2017-03-14 13:27:18 +01:00
faiface fa57a41d2a make doc more readable 2017-03-14 13:20:26 +01:00
faiface 35a14c2d18 rename ZM -> IM 2017-03-14 13:15:53 +01:00
faiface 203adc914b change Rect to have Min, Max instead of Pos, Size 2017-03-13 23:52:34 +01:00
faiface f0394ec7d1 replace Transform by much simpler Matrix 2017-03-06 19:58:24 +01:00
faiface 28f0f01173 add Lerp function 2017-03-05 11:47:18 +01:00
faiface 77c39d03c7 rename Vec.Apply -> Vec.Map 2017-03-01 23:13:14 +01:00
faiface a7fdbd618e add Vec.Apply 2017-03-01 23:12:48 +01:00
faiface 7974f86c4a add Rect.Contains(Vec) bool method 2017-02-25 18:38:22 +01:00
faiface bc97fa00b8 improve doc in pixel 2017-01-25 18:55:17 +01:00
faiface 9096277914 normalized most of lines to <=100 chars 2016-12-30 17:43:26 +01:00
faiface c8ee45dd4f add Rect 2016-12-05 23:19:31 +01:00
faiface 12575af796 rename vec.go to geometry.go (stuff coming) 2016-12-05 22:56:16 +01:00