Commit Graph

90 Commits

Author SHA1 Message Date
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