You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
People with a trained eye and a little of trigonometric background will immediately recognize the [affine transform of a 2D point], commonly used in computer graphics or robotics.
24
+
People with a trained eye (and a little of trigonometric background) will immediately recognize the [affine transform of a 2D point], commonly used in computer graphics and robotics.
25
25
26
26
Don't you see anything we can do better? Of course:
27
27
@@ -35,7 +35,7 @@ double y1 = x*Sin + y*Cos + ty;
35
35
The cost of trigonometric functions is relatively high and there is absolutely no reason to compute twice the same value.
36
36
The latter code will be 2x times faster then the former, because the cost of multiplication and sum is really low compared with `sin()` and `cos()`.
37
37
38
-
In general, if the number of potential angles you need to test is finite, consider to use look-up-table where you can store pre-computed values.
38
+
In general, if the number of potential angles you need to test is not extremely high, consider to use look-up-table where you can store pre-computed values.
39
39
40
40
This is the case, for instance, of laser scan data, that needs to be converted from polar coordinates to cartesian ones.
41
41
@@ -46,27 +46,27 @@ A naive implementation would invoke trigonometric functions for each point (in t
46
46
```c++
47
47
// Conceptual operation (inefficient)
48
48
// Data is usually stored in a vector of distances
This is a simple example; what you should learn from it is that, whenever an operation is expensive to compute (SQL queries, stateless mathematical operations), you should consider to use a cached value and or to build a look-up-table.
100
+
This is a simple example; what you should learn from this is that, whenever an operation is expensive to compute (SQL queries, stateless mathematical operations), you should consider to use a cached value and or to build a look-up-table.
101
101
102
-
But, as always, measure first, to be sure that the optimization is actually relevant ;)
102
+
But, as always, **measure first** to be sure that the optimization is actually relevant ;)
0 commit comments