Commit ee06f3e
committed
Doc: Explain how Qt computes arcs and ellipses
The angle arguments of QPainterPath::arcTo(), QPainterPath::arcMoveTo()
and the QPainter arc functions are eccentric angles: they parameterize
the ellipse fitted into the bounding rectangle rather than measuring a
direction from its center. In general the two coincide only for a square
bounding rectangle. On a 400 by 100 rectangle, an angle of 45 degrees
yields a point roughly 14 degrees above the horizontal as seen from the
center.
Separately, arcs and ellipses are approximated with cubic Bezier curves
scaled by QT_PATH_KAPPA rather than evaluated trigonometrically, so the
resulting points sit slightly off where qSin() and qCos() would place
them. For a circle the offset stays below 0.1% of the radius.
Neither property was documented, which repeatedly surprises users who
build paths from trigonometry and then compare the result against Qt's.
Document both in a new "Arcs and Ellipses" section of the QPainterPath
overview, reference it from the affected functions, and note the
approximation next to the existing stroker limitation in the QPainter
overview.
The eccentric angle behavior was judged intentional in QTBUG-2644 in
2009, where adding a doc hint was agreed on but never done.
Fixes: QTBUG-149880
Pick-to: 6.12 6.11 6.8
Change-Id: Ib1dcb6c6fe27533ef582acc38b15195a87f71269
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>1 parent dd55ea9 commit ee06f3e
2 files changed
Lines changed: 63 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1307 | 1307 | | |
1308 | 1308 | | |
1309 | 1309 | | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
1310 | 1318 | | |
1311 | 1319 | | |
1312 | 1320 | | |
| |||
4170 | 4178 | | |
4171 | 4179 | | |
4172 | 4180 | | |
4173 | | - | |
| 4181 | + | |
| 4182 | + | |
| 4183 | + | |
| 4184 | + | |
4174 | 4185 | | |
4175 | 4186 | | |
4176 | 4187 | | |
| |||
4235 | 4246 | | |
4236 | 4247 | | |
4237 | 4248 | | |
4238 | | - | |
| 4249 | + | |
| 4250 | + | |
| 4251 | + | |
| 4252 | + | |
4239 | 4253 | | |
4240 | 4254 | | |
4241 | 4255 | | |
| |||
4306 | 4320 | | |
4307 | 4321 | | |
4308 | 4322 | | |
4309 | | - | |
| 4323 | + | |
| 4324 | + | |
| 4325 | + | |
| 4326 | + | |
4310 | 4327 | | |
4311 | 4328 | | |
4312 | 4329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
228 | 257 | | |
229 | 258 | | |
230 | 259 | | |
| |||
895 | 924 | | |
896 | 925 | | |
897 | 926 | | |
898 | | - | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
899 | 931 | | |
900 | 932 | | |
901 | 933 | | |
| |||
967 | 999 | | |
968 | 1000 | | |
969 | 1001 | | |
970 | | - | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
971 | 1006 | | |
972 | | - | |
| 1007 | + | |
| 1008 | + | |
973 | 1009 | | |
974 | 1010 | | |
975 | 1011 | | |
| |||
1102 | 1138 | | |
1103 | 1139 | | |
1104 | 1140 | | |
1105 | | - | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
1106 | 1145 | | |
1107 | 1146 | | |
1108 | 1147 | | |
| |||
0 commit comments