1 | # Sigma Current Coordinate System
|
2 |
|
3 | ## Referentials
|
4 |
|
5 | 1. Graph coordinates `graph`: arbitrary, range from `-Infinity` to `Infinity`.
|
6 | 2. Rescaled graph coordinates `rescaled`: centered on `0.5`, proportion between min/max of `graph`. Ranges naturally from `0` to `1`.
|
7 | 3. Container pixel coordinates `container`: origin is top left and range from `0` to max pixel width/height.
|
8 | 4. Webgl coordinates `webgl`: centered on `0`, screen space ranges from `-1` to `1`.
|
9 | 5. Quadtree coordinates `quadtree`: same as `rescaled` with `-1`. Can't remember why but won't work else. `quadtree` also normalize sizes by dividing them by container width.
|
10 |
|
11 | ## Translations
|
12 |
|
13 | * `renderers/utils.createNormalizationFunction`: creates a function mapping `graph` to `rescaled`. It also returns an inverse function mappping `rescaled` to `graph`. It must be actualized every time `graph` coordinates are updated (can be optimized by recomputing only if bounds changed).
|
14 | * `camera.graphToViewport`: maps `rescaled` to `container`.
|
15 | * `camera.viewportToGraph`: maps the inverse `container` to `rescaled`.
|
16 | * `renderers/webgl/utils.matrixFromCamera`: return a translation matrix to map `rescaled` to `webgl` and used in vertex shaders.
|
17 |
|
18 | ## Examples
|
19 |
|
20 | ### Click detection
|
21 |
|
22 | 1. Find nodes in the quadtree using event positions.
|
23 | 2. Apply size ratio of the camera.
|
24 | 3. Map node positions from `rescaled` (cache) to `container`.
|
25 | 4. Compute collisions.
|
26 |
|
27 | ### Drag
|
28 |
|
29 | 1. Map event positions from `container` to `rescaled`.
|
30 | 2. Use inverse normalization function to map `rescaled` to `graph`.
|
31 | 3. Set position in `graph`.
|