1 SkPoint Reference 2 === 3 4 # <a name="Point"></a> Point 5 6 ## <a name="Overview"></a> Overview 7 8 ## <a name="Overview_Subtopic"></a> Overview Subtopic 9 10 | name | description | 11 | --- | --- | 12 | <a href="#Constructor">Constructor</a> | functions that construct <a href="#SkPoint">SkPoint</a> | 13 | <a href="#Member_Function">Member Function</a> | static functions and member methods | 14 | <a href="#Member">Member</a> | member values | 15 | <a href="#Operator">Operator</a> | operator overloading methods | 16 | <a href="#Related_Function">Related Function</a> | similar methods grouped together | 17 18 # <a name="SkPoint"></a> Struct SkPoint 19 <a href="#SkPoint">SkPoint</a> holds two 32 bit floating point coordinates. 20 21 ## <a name="Related_Function"></a> Related Function 22 23 | name | description | 24 | --- | --- | 25 | <a href="#SkPoint_Offset">Offset</a> | moves sides | 26 | <a href="#Property">Property</a> | member values | 27 | <a href="#Set">Set</a> | replaces all values | 28 29 ## <a name="Member_Function"></a> Member Function 30 31 | name | description | 32 | --- | --- | 33 | <a href="#SkPoint_CrossProduct">CrossProduct</a> | returns cross product | 34 | <a href="#SkPoint_Distance">Distance</a> | returns straight-line distance between points | 35 | <a href="#SkPoint_DotProduct">DotProduct</a> | returns dot product | 36 | <a href="#SkPoint_Length">Length</a> | returns straight-line distance to origin | 37 | <a href="#SkPoint_Make">Make</a> | constructs from <a href="undocumented#SkScalar">SkScalar</a> inputs | 38 | <a href="#SkPoint_Normalize">Normalize</a> | sets length to one, and returns prior length | 39 | <a href="#SkPoint_Offset">Offset</a> | translates <a href="#Point">Point</a> array | 40 | <a href="#SkPoint_cross">cross</a> | returns cross product | 41 | <a href="#SkPoint_distanceToOrigin">distanceToOrigin</a> | returns straight-line distance to origin | 42 | <a href="#SkPoint_dot">dot</a> | returns dot product | 43 | <a href="#SkPoint_equals">equals</a> | returns true if <a href="#Point">Points</a> are equal | 44 | <a href="#SkPoint_isFinite">isFinite</a> | returns true if no member is infinite or NaN | 45 | <a href="#SkPoint_isZero">isZero</a> | returns true if both members equal zero | 46 | <a href="#SkPoint_iset">iset</a> | sets to integer input | 47 | <a href="#SkPoint_length">length</a> | returns straight-line distance to origin | 48 | <a href="#SkPoint_negate">negate</a> | reverses the sign of both members | 49 | <a href="#SkPoint_normalize">normalize</a> | sets length to one, preserving direction | 50 | <a href="#SkPoint_offset">offset</a> | translates <a href="#Point">Point</a> | 51 | <a href="#SkPoint_scale">scale</a> | multiplies <a href="#Point">Point</a> by scale factor | 52 | <a href="#SkPoint_set">set</a> | sets to <a href="undocumented#SkScalar">SkScalar</a> input | 53 | <a href="#SkPoint_setAbs">setAbs</a> | sets sign of both members to positive | 54 | <a href="#SkPoint_setLength">setLength</a> | sets straight-line distance to origin | 55 | <a href="#SkPoint_setNormalize">setNormalize</a> | sets length to one, in direction of (x, y) | 56 | <a href="#SkPoint_x">x</a> | returns <a href="#SkPoint_fX">fX</a> | 57 | <a href="#SkPoint_y">y</a> | returns <a href="#SkPoint_fY">fY</a> | 58 59 ## <a name="Member"></a> Member 60 61 | name | description | 62 | --- | --- | 63 | <a href="#SkPoint_fX">fX</a> | x-axis value | 64 | <a href="#SkPoint_fY">fY</a> | y-axis value | 65 66 <a name="SkPoint_fX"> <code><strong>SkScalar fX</strong></code> </a> 67 68 x-axis value used by both <a href="#Point">Point</a> and <a href="#Vector">Vector</a>. May contain any value, including 69 infinities and NaN. 70 71 <a name="SkPoint_fY"> <code><strong>SkScalar fY</strong></code> </a> 72 73 y-axis value used by both <a href="#Point">Point</a> and <a href="#Vector">Vector</a>. May contain any value, including 74 infinities and NaN. 75 76 ## <a name="Constructor"></a> Constructor 77 78 | name | description | 79 | --- | --- | 80 | <a href="#SkPoint_Make">Make</a> | constructs from <a href="undocumented#SkScalar">SkScalar</a> inputs | 81 82 <a name="SkPoint_Make"></a> 83 ## Make 84 85 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 86 static constexpr SkPoint Make(SkScalar x, SkScalar y) 87 </pre> 88 89 Sets <a href="#SkPoint_fX">fX</a> to x, <a href="#SkPoint_fY">fY</a> to y. Used both to set <a href="#Point">Point</a> and <a href="#Vector">Vector</a>. 90 91 ### Parameters 92 93 <table> <tr> <td><a name="SkPoint_Make_x"> <code><strong>x </strong></code> </a></td> <td> 94 <a href="undocumented#SkScalar">SkScalar</a> x-axis value of constructed <a href="#Point">Point</a> or <a href="#Vector">Vector</a></td> 95 </tr> <tr> <td><a name="SkPoint_Make_y"> <code><strong>y </strong></code> </a></td> <td> 96 <a href="undocumented#SkScalar">SkScalar</a> y-axis value of constructed <a href="#Point">Point</a> or <a href="#Vector">Vector</a></td> 97 </tr> 98 </table> 99 100 ### Return Value 101 102 <a href="#Point">Point</a> (x, y) 103 104 ### Example 105 106 <div><fiddle-embed name="d266e70977847001f7c42f8a2513bee7"> 107 108 #### Example Output 109 110 ~~~~ 111 all equal 112 ~~~~ 113 114 </fiddle-embed></div> 115 116 ### See Also 117 118 <a href="#SkPoint_set">set</a> <a href="#SkPoint_iset">iset</a><sup><a href="#SkPoint_iset_2">[2]</a></sup> <a href="SkIPoint_Reference#SkIPoint_Make">SkIPoint::Make</a> 119 120 --- 121 122 ## <a name="Property"></a> Property 123 124 | name | description | 125 | --- | --- | 126 | <a href="#SkPoint_Distance">Distance</a> | returns straight-line distance between points | 127 | <a href="#SkPoint_Length">Length</a> | returns straight-line distance to origin | 128 | <a href="#SkPoint_distanceToOrigin">distanceToOrigin</a> | returns straight-line distance to origin | 129 | <a href="#SkPoint_isFinite">isFinite</a> | returns true if no member is infinite or NaN | 130 | <a href="#SkPoint_isZero">isZero</a> | returns true if both members equal zero | 131 | <a href="#SkPoint_length">length</a> | returns straight-line distance to origin | 132 | <a href="#SkPoint_x">x</a> | returns <a href="#SkPoint_fX">fX</a> | 133 | <a href="#SkPoint_y">y</a> | returns <a href="#SkPoint_fY">fY</a> | 134 135 <a name="SkPoint_x"></a> 136 ## x 137 138 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 139 SkScalar x() const 140 </pre> 141 142 Returns x-axis value of <a href="#Point">Point</a> or <a href="#Vector">Vector</a>. 143 144 ### Return Value 145 146 <a href="#SkPoint_fX">fX</a> 147 148 ### Example 149 150 <div><fiddle-embed name="9f3fe446b800ae1d940785d438634941"> 151 152 #### Example Output 153 154 ~~~~ 155 pt1.fX == pt1.x() 156 ~~~~ 157 158 </fiddle-embed></div> 159 160 ### See Also 161 162 <a href="#SkPoint_y">y</a> <a href="SkIPoint_Reference#SkIPoint_x">SkIPoint::x()</a> 163 164 --- 165 166 <a name="SkPoint_y"></a> 167 ## y 168 169 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 170 SkScalar y() const 171 </pre> 172 173 Returns y-axis value of <a href="#Point">Point</a> or <a href="#Vector">Vector</a>. 174 175 ### Return Value 176 177 <a href="#SkPoint_fY">fY</a> 178 179 ### Example 180 181 <div><fiddle-embed name="4c962850c2dbea4d2325df469400680e"> 182 183 #### Example Output 184 185 ~~~~ 186 pt1.fY == pt1.y() 187 ~~~~ 188 189 </fiddle-embed></div> 190 191 ### See Also 192 193 <a href="#SkPoint_x">x</a> <a href="SkIPoint_Reference#SkIPoint_y">SkIPoint::y()</a> 194 195 --- 196 197 <a name="SkPoint_isZero"></a> 198 ## isZero 199 200 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 201 bool isZero() const 202 </pre> 203 204 Returns true if <a href="#SkPoint_fX">fX</a> and <a href="#SkPoint_fY">fY</a> are both zero. 205 206 ### Return Value 207 208 true if <a href="#SkPoint_fX">fX</a> is zero and <a href="#SkPoint_fY">fY</a> is zero 209 210 ### Example 211 212 <div><fiddle-embed name="81b9665110b88ef6bcbc20464aed7da1"> 213 214 #### Example Output 215 216 ~~~~ 217 pt.fX=+0 pt.fY=-0 218 pt.isZero() == true 219 ~~~~ 220 221 </fiddle-embed></div> 222 223 ### See Also 224 225 <a href="#SkPoint_isFinite">isFinite</a> <a href="SkIPoint_Reference#SkIPoint_isZero">SkIPoint::isZero</a> 226 227 --- 228 229 ## <a name="Set"></a> Set 230 231 | name | description | 232 | --- | --- | 233 | <a href="#SkPoint_iset">iset</a> | sets to integer input | 234 | | <a href="#SkPoint_iset">iset(int32 t x, int32 t y)</a> | 235 | | <a href="#SkPoint_iset_2">iset(const SkIPoint& p)</a> | 236 | <a href="#SkPoint_normalize">normalize</a> | sets length to one, preserving direction | 237 | <a href="#SkPoint_set">set</a> | sets to <a href="undocumented#SkScalar">SkScalar</a> input | 238 | <a href="#SkPoint_setAbs">setAbs</a> | sets sign of both members to positive | 239 | <a href="#SkPoint_setLength">setLength</a> | sets straight-line distance to origin | 240 | | <a href="#SkPoint_setLength">setLength(SkScalar length)</a> | 241 | | <a href="#SkPoint_setLength_2">setLength(SkScalar x, SkScalar y, SkScalar length)</a> | 242 | <a href="#SkPoint_setNormalize">setNormalize</a> | sets length to one, in direction of (x, y) | 243 244 <a name="SkPoint_set"></a> 245 ## set 246 247 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 248 void set(SkScalar x, SkScalar y) 249 </pre> 250 251 Sets <a href="#SkPoint_fX">fX</a> to x and <a href="#SkPoint_fY">fY</a> to y. 252 253 ### Parameters 254 255 <table> <tr> <td><a name="SkPoint_set_x"> <code><strong>x </strong></code> </a></td> <td> 256 new value for <a href="#SkPoint_fX">fX</a></td> 257 </tr> <tr> <td><a name="SkPoint_set_y"> <code><strong>y </strong></code> </a></td> <td> 258 new value for <a href="#SkPoint_fY">fY</a></td> 259 </tr> 260 </table> 261 262 ### Example 263 264 <div><fiddle-embed name="d08d1e7dafcad4342d1619fdbb2f5781"> 265 266 #### Example Output 267 268 ~~~~ 269 pt1 == pt2 270 ~~~~ 271 272 </fiddle-embed></div> 273 274 ### See Also 275 276 <a href="#SkPoint_iset">iset</a><sup><a href="#SkPoint_iset_2">[2]</a></sup> <a href="#SkPoint_Make">Make</a> 277 278 --- 279 280 <a name="SkPoint_iset"></a> 281 ## iset 282 283 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 284 void iset(int32_t x, int32_t y) 285 </pre> 286 287 Sets <a href="#SkPoint_fX">fX</a> to x and <a href="#SkPoint_fY">fY</a> to y, promoting integers to <a href="undocumented#SkScalar">SkScalar</a> values. 288 289 Assigning a large integer value directly to <a href="#SkPoint_fX">fX</a> or <a href="#SkPoint_fY">fY</a> may cause a compiler 290 error, triggered by narrowing conversion of int to <a href="undocumented#SkScalar">SkScalar</a>. This safely 291 casts x and y to avoid the error. 292 293 ### Parameters 294 295 <table> <tr> <td><a name="SkPoint_iset_x"> <code><strong>x </strong></code> </a></td> <td> 296 new value for <a href="#SkPoint_fX">fX</a></td> 297 </tr> <tr> <td><a name="SkPoint_iset_y"> <code><strong>y </strong></code> </a></td> <td> 298 new value for <a href="#SkPoint_fY">fY</a></td> 299 </tr> 300 </table> 301 302 ### Example 303 304 <div><fiddle-embed name="0d9e8ed734981b5b113f22c7bfde5357"></fiddle-embed></div> 305 306 ### See Also 307 308 <a href="#SkPoint_set">set</a> <a href="#SkPoint_Make">Make</a> <a href="SkIPoint_Reference#SkIPoint_set">SkIPoint::set</a> 309 310 --- 311 312 <a name="SkPoint_iset_2"></a> 313 314 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 315 void iset(const SkIPoint& p) 316 </pre> 317 318 Sets <a href="#SkPoint_fX">fX</a> to <a href="#SkPoint_iset_2_p">p</a>.<a href="#SkPoint_fX">fX</a> and <a href="#SkPoint_fY">fY</a> to <a href="#SkPoint_iset_2_p">p</a>.<a href="#SkPoint_fY">fY</a>, promoting integers to <a href="undocumented#SkScalar">SkScalar</a> values. 319 320 Assigning an <a href="SkIPoint_Reference#IPoint">IPoint</a> containing a large integer value directly to <a href="#SkPoint_fX">fX</a> or <a href="#SkPoint_fY">fY</a> may 321 cause a compiler error, triggered by narrowing conversion of int to <a href="undocumented#SkScalar">SkScalar</a>. 322 This safely casts <a href="#SkPoint_iset_2_p">p</a>.<a href="#SkPoint_fX">fX</a> and <a href="#SkPoint_iset_2_p">p</a>.<a href="#SkPoint_fY">fY</a> to avoid the error. 323 324 ### Parameters 325 326 <table> <tr> <td><a name="SkPoint_iset_2_p"> <code><strong>p </strong></code> </a></td> <td> 327 <a href="SkIPoint_Reference#IPoint">IPoint</a> members promoted to <a href="undocumented#SkScalar">SkScalar</a></td> 328 </tr> 329 </table> 330 331 ### Example 332 333 <div><fiddle-embed name="12b7164a769e232bb772f19c59600ee7"> 334 335 #### Example Output 336 337 ~~~~ 338 iPt: -2147483647, 2147483647 339 fPt: -2.14748e+09, 2.14748e+09 340 ~~~~ 341 342 </fiddle-embed></div> 343 344 ### See Also 345 346 <a href="#SkPoint_set">set</a> <a href="#SkPoint_Make">Make</a> <a href="SkIPoint_Reference#SkIPoint_set">SkIPoint::set</a> 347 348 --- 349 350 <a name="SkPoint_setAbs"></a> 351 ## setAbs 352 353 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 354 void setAbs(const SkPoint& pt) 355 </pre> 356 357 Sets <a href="#SkPoint_fX">fX</a> to absolute value of <a href="#SkPoint_setAbs_pt">pt</a>.<a href="#SkPoint_fX">fX</a>; and <a href="#SkPoint_fY">fY</a> to absolute value of <a href="#SkPoint_setAbs_pt">pt</a>.<a href="#SkPoint_fY">fY</a>. 358 359 ### Parameters 360 361 <table> <tr> <td><a name="SkPoint_setAbs_pt"> <code><strong>pt </strong></code> </a></td> <td> 362 members providing magnitude for <a href="#SkPoint_fX">fX</a> and <a href="#SkPoint_fY">fY</a></td> 363 </tr> 364 </table> 365 366 ### Example 367 368 <div><fiddle-embed name="7f70860e820b67a347cff03c00488426"> 369 370 #### Example Output 371 372 ~~~~ 373 pt: 0, -0 abs: 0, 0 374 pt: -1, -2 abs: 1, 2 375 pt: inf, -inf abs: inf, inf 376 pt: nan, -nan abs: nan, nan 377 ~~~~ 378 379 </fiddle-embed></div> 380 381 ### See Also 382 383 <a href="#SkPoint_set">set</a> <a href="#SkPoint_Make">Make</a> <a href="#SkPoint_negate">negate</a> 384 385 --- 386 387 ## <a name="Offset"></a> Offset 388 389 | name | description | 390 | --- | --- | 391 | <a href="#SkPoint_Normalize">Normalize</a> | sets length to one, and returns prior length | 392 | <a href="#SkPoint_Offset">Offset</a> | translates <a href="#Point">Point</a> array | 393 | | <a href="#SkPoint_Offset">Offset(SkPoint points[], int count, const SkVector& offset)</a> | 394 | | <a href="#SkPoint_Offset_2">Offset(SkPoint points[], int count, SkScalar dx, SkScalar dy)</a> | 395 | <a href="#SkPoint_offset">offset</a> | translates <a href="#Point">Point</a> | 396 | <a href="#SkPoint_scale">scale</a> | multiplies <a href="#Point">Point</a> by scale factor | 397 | | <a href="#SkPoint_scale">scale(SkScalar scale, SkPoint* dst)</a> const | 398 | | <a href="#SkPoint_scale_2">scale(SkScalar value)</a> | 399 400 <a name="SkPoint_Offset"></a> 401 ## Offset 402 403 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 404 static void Offset(SkPoint points[], int count, const SkVector& offset) 405 </pre> 406 407 Adds offset to each <a href="#Point">Point</a> in <a href="#SkPoint_Offset_points">points</a> array with <a href="#SkPoint_Offset_count">count</a> entries. 408 409 ### Parameters 410 411 <table> <tr> <td><a name="SkPoint_Offset_points"> <code><strong>points </strong></code> </a></td> <td> 412 <a href="#Point">Point</a> array</td> 413 </tr> <tr> <td><a name="SkPoint_Offset_count"> <code><strong>count </strong></code> </a></td> <td> 414 entries in array</td> 415 </tr> <tr> <td><a name="SkPoint_Offset_offset"> <code><strong>offset </strong></code> </a></td> <td> 416 <a href="#Vector">Vector</a> added to <a href="#SkPoint_Offset_points">points</a></td> 417 </tr> 418 </table> 419 420 ### Example 421 422 <div><fiddle-embed name="f0f24726df78a5d797bcf311e694a0a3"></fiddle-embed></div> 423 424 ### See Also 425 426 <a href="#SkPoint_offset">offset</a> <a href="#SkPoint_addto_operator">operator+=(const SkVector& v)</a> 427 428 --- 429 430 <a name="SkPoint_Offset_2"></a> 431 432 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 433 static void Offset(SkPoint points[], int count, SkScalar dx, SkScalar dy) 434 </pre> 435 436 Adds offset (<a href="#SkPoint_Offset_2_dx">dx</a>, <a href="#SkPoint_Offset_2_dy">dy</a>) to each <a href="#Point">Point</a> in <a href="#SkPoint_Offset_2_points">points</a> array of length <a href="#SkPoint_Offset_2_count">count</a>. 437 438 ### Parameters 439 440 <table> <tr> <td><a name="SkPoint_Offset_2_points"> <code><strong>points </strong></code> </a></td> <td> 441 <a href="#Point">Point</a> array</td> 442 </tr> <tr> <td><a name="SkPoint_Offset_2_count"> <code><strong>count </strong></code> </a></td> <td> 443 entries in array</td> 444 </tr> <tr> <td><a name="SkPoint_Offset_2_dx"> <code><strong>dx </strong></code> </a></td> <td> 445 added to <a href="#SkPoint_fX">fX</a> in <a href="#SkPoint_Offset_2_points">points</a></td> 446 </tr> <tr> <td><a name="SkPoint_Offset_2_dy"> <code><strong>dy </strong></code> </a></td> <td> 447 added to <a href="#SkPoint_fY">fY</a> in <a href="#SkPoint_Offset_2_points">points</a></td> 448 </tr> 449 </table> 450 451 ### Example 452 453 <div><fiddle-embed name="532849faa838de885b86d3ebffae3712"></fiddle-embed></div> 454 455 ### See Also 456 457 <a href="#SkPoint_offset">offset</a> <a href="#SkPoint_addto_operator">operator+=(const SkVector& v)</a> 458 459 --- 460 461 <a name="SkPoint_offset"></a> 462 ## offset 463 464 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 465 void offset(SkScalar dx, SkScalar dy) 466 </pre> 467 468 Adds offset (<a href="#SkPoint_offset_dx">dx</a>, <a href="#SkPoint_offset_dy">dy</a>) to <a href="#Point">Point</a>. 469 470 ### Parameters 471 472 <table> <tr> <td><a name="SkPoint_offset_dx"> <code><strong>dx </strong></code> </a></td> <td> 473 added to <a href="#SkPoint_fX">fX</a></td> 474 </tr> <tr> <td><a name="SkPoint_offset_dy"> <code><strong>dy </strong></code> </a></td> <td> 475 added to <a href="#SkPoint_fY">fY</a></td> 476 </tr> 477 </table> 478 479 ### Example 480 481 <div><fiddle-embed name="02750ceaa874f956e6e6544ef6b858ee"></fiddle-embed></div> 482 483 ### See Also 484 485 <a href="#SkPoint_Offset">Offset</a><sup><a href="#SkPoint_Offset_2">[2]</a></sup> <a href="#SkPoint_addto_operator">operator+=(const SkVector& v)</a> 486 487 --- 488 489 <a name="SkPoint_length"></a> 490 ## length 491 492 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 493 SkScalar length() const 494 </pre> 495 496 Returns the Euclidean_Distance from origin, computed as: 497 498 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 499 sqrt(fX * fX + fY * fY)</pre> 500 501 . 502 503 ### Return Value 504 505 straight-line distance to origin 506 507 ### Example 508 509 <div><fiddle-embed name="8363ab179447ee4b827679e20d3d81eb"></fiddle-embed></div> 510 511 ### See Also 512 513 <a href="#SkPoint_distanceToOrigin">distanceToOrigin</a> <a href="#SkPoint_Length">Length</a> <a href="#SkPoint_setLength">setLength</a><sup><a href="#SkPoint_setLength_2">[2]</a></sup> <a href="#SkPoint_Distance">Distance</a> 514 515 --- 516 517 <a name="SkPoint_distanceToOrigin"></a> 518 ## distanceToOrigin 519 520 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 521 SkScalar distanceToOrigin() const 522 </pre> 523 524 Returns the Euclidean_Distance from origin, computed as: 525 526 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 527 sqrt(fX * fX + fY * fY)</pre> 528 529 . 530 531 ### Return Value 532 533 straight-line distance to origin 534 535 ### Example 536 537 <div><fiddle-embed name="812cf26d91b1cdcd2c6b9438a8172518"></fiddle-embed></div> 538 539 ### See Also 540 541 <a href="#SkPoint_length">length</a> <a href="#SkPoint_Length">Length</a> <a href="#SkPoint_setLength">setLength</a><sup><a href="#SkPoint_setLength_2">[2]</a></sup> <a href="#SkPoint_Distance">Distance</a> 542 543 --- 544 545 <a name="SkPoint_normalize"></a> 546 ## normalize 547 548 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 549 bool normalize() 550 </pre> 551 552 Scales (<a href="#SkPoint_fX">fX</a>, <a href="#SkPoint_fY">fY</a>) so that <a href="#SkPoint_length">length</a> returns one, while preserving ratio of <a href="#SkPoint_fX">fX</a> to <a href="#SkPoint_fY">fY</a>, 553 if possible. If prior length is nearly zero, sets <a href="#Vector">Vector</a> to (0, 0) and returns 554 false; otherwise returns true. 555 556 ### Return Value 557 558 true if former length is not zero or nearly zero 559 560 ### Example 561 562 <div><fiddle-embed name="d84fce292d86c7d9ef37ae2d179c03c7"></fiddle-embed></div> 563 564 ### See Also 565 566 <a href="#SkPoint_Normalize">Normalize</a> <a href="#SkPoint_setLength">setLength</a><sup><a href="#SkPoint_setLength_2">[2]</a></sup> <a href="#SkPoint_length">length</a> <a href="#SkPoint_Length">Length</a> 567 568 --- 569 570 <a name="SkPoint_setNormalize"></a> 571 ## setNormalize 572 573 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 574 bool setNormalize(SkScalar x, SkScalar y) 575 </pre> 576 577 Sets <a href="#Vector">Vector</a> to (x, y) scaled so <a href="#SkPoint_length">length</a> returns one, and so that 578 (<a href="#SkPoint_fX">fX</a>, <a href="#SkPoint_fY">fY</a>) is proportional to (x, y). If (x, y) length is nearly zero, 579 sets <a href="#Vector">Vector</a> to (0, 0) and returns false; otherwise returns true. 580 581 ### Parameters 582 583 <table> <tr> <td><a name="SkPoint_setNormalize_x"> <code><strong>x </strong></code> </a></td> <td> 584 proportional value for <a href="#SkPoint_fX">fX</a></td> 585 </tr> <tr> <td><a name="SkPoint_setNormalize_y"> <code><strong>y </strong></code> </a></td> <td> 586 proportional value for <a href="#SkPoint_fY">fY</a></td> 587 </tr> 588 </table> 589 590 ### Return Value 591 592 true if (x, y) length is not zero or nearly zero 593 594 ### Example 595 596 <div><fiddle-embed name="3e4f147d143a388802484bf0d26534c2"></fiddle-embed></div> 597 598 ### See Also 599 600 <a href="#SkPoint_normalize">normalize</a> <a href="#SkPoint_setLength">setLength</a><sup><a href="#SkPoint_setLength_2">[2]</a></sup> 601 602 --- 603 604 <a name="SkPoint_setLength"></a> 605 ## setLength 606 607 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 608 bool setLength(SkScalar length) 609 </pre> 610 611 Scales <a href="#Vector">Vector</a> so that <a href="#SkPoint_distanceToOrigin">distanceToOrigin</a> returns length, if possible. If former 612 length is nearly zero, sets <a href="#Vector">Vector</a> to (0, 0) and return false; otherwise returns 613 true. 614 615 ### Parameters 616 617 <table> <tr> <td><a name="SkPoint_setLength_length"> <code><strong>length </strong></code> </a></td> <td> 618 straight-line distance to origin</td> 619 </tr> 620 </table> 621 622 ### Return Value 623 624 true if former length is not zero or nearly zero 625 626 ### Example 627 628 <div><fiddle-embed name="cbe7db206ece825aa3b9b7c3256aeaf0"></fiddle-embed></div> 629 630 ### See Also 631 632 <a href="#SkPoint_length">length</a> <a href="#SkPoint_Length">Length</a> <a href="#SkPoint_setNormalize">setNormalize</a> <a href="#SkPoint_setAbs">setAbs</a> 633 634 --- 635 636 <a name="SkPoint_setLength_2"></a> 637 638 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 639 bool setLength(SkScalar x, SkScalar y, SkScalar length) 640 </pre> 641 642 Sets <a href="#Vector">Vector</a> to (x, y) scaled to length, if possible. If former 643 length is nearly zero, sets <a href="#Vector">Vector</a> to (0, 0) and return false; otherwise returns 644 true. 645 646 ### Parameters 647 648 <table> <tr> <td><a name="SkPoint_setLength_2_x"> <code><strong>x </strong></code> </a></td> <td> 649 proportional value for <a href="#SkPoint_fX">fX</a></td> 650 </tr> <tr> <td><a name="SkPoint_setLength_2_y"> <code><strong>y </strong></code> </a></td> <td> 651 proportional value for <a href="#SkPoint_fY">fY</a></td> 652 </tr> <tr> <td><a name="SkPoint_setLength_2_length"> <code><strong>length </strong></code> </a></td> <td> 653 straight-line distance to origin</td> 654 </tr> 655 </table> 656 657 ### Return Value 658 659 true if (x, y) length is not zero or nearly zero 660 661 ### Example 662 663 <div><fiddle-embed name="3cc0662b6fbbee1fe3442a0acfece22c"></fiddle-embed></div> 664 665 ### See Also 666 667 <a href="#SkPoint_length">length</a> <a href="#SkPoint_Length">Length</a> <a href="#SkPoint_setNormalize">setNormalize</a> <a href="#SkPoint_setAbs">setAbs</a> 668 669 --- 670 671 ## <a name="Operator"></a> Operator 672 673 | name | description | 674 | --- | --- | 675 | <a href="#SkPoint_CrossProduct">CrossProduct</a> | returns cross product | 676 | <a href="#SkPoint_DotProduct">DotProduct</a> | returns dot product | 677 | <a href="#SkPoint_cross">cross</a> | returns cross product | 678 | <a href="#SkPoint_dot">dot</a> | returns dot product | 679 | <a href="#SkPoint_equals">equals</a> | returns true if <a href="#Point">Points</a> are equal | 680 | <a href="#SkPoint_negate">negate</a> | reverses the sign of both members | 681 | <a href="#SkPoint_notequal_operator">operator!=(const SkPoint& a, const SkPoint& b)</a> | returns true if <a href="#Point">Point</a> are unequal | 682 | <a href="#SkPoint_multiply_operator">operator*(SkScalar scale) const</a> | returns <a href="#Point">Point</a> multiplied by scale | 683 | <a href="#SkPoint_multiplyby_operator">operator*=(SkScalar scale)</a> | multiplies <a href="#Point">Point</a> by scale factor | 684 | <a href="#SkPoint_add_operator">operator+(const SkPoint& a, const SkVector& b)</a> | returns <a href="#Point">Point</a> offset by <a href="#Vector">Vector</a> | 685 | <a href="#SkPoint_addto_operator">operator+=(const SkVector& v)</a> | adds <a href="#Vector">Vector</a> to <a href="#Point">Point</a> | 686 | <a href="#SkPoint_minus_operator">operator-() const</a> | reverses sign of <a href="#Point">Point</a> | 687 | <a href="#SkPoint_subtract_operator">operator-(const SkPoint& a, const SkPoint& b)</a> | returns <a href="#Vector">Vector</a> between <a href="#Point">Points</a> | 688 | <a href="#SkPoint_subtractfrom_operator">operator-=(const SkVector& v)</a> | subtracts <a href="#Vector">Vector</a> from <a href="#Point">Point</a> | 689 | <a href="#SkPoint_equal_operator">operator==(const SkPoint& a, const SkPoint& b)</a> | returns true if <a href="#Point">Point</a> are equal | 690 691 <a name="SkPoint_scale"></a> 692 ## scale 693 694 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 695 void scale(SkScalar scale, SkPoint* dst) const 696 </pre> 697 698 Sets <a href="#SkPoint_scale_dst">dst</a> to <a href="#Point">Point</a> times scale. <a href="#SkPoint_scale_dst">dst</a> may be <a href="#Point">Point</a> to modify <a href="#Point">Point</a> in place. 699 700 ### Parameters 701 702 <table> <tr> <td><a name="SkPoint_scale_scale"> <code><strong>scale </strong></code> </a></td> <td> 703 factor to multiply <a href="#Point">Point</a> by</td> 704 </tr> <tr> <td><a name="SkPoint_scale_dst"> <code><strong>dst </strong></code> </a></td> <td> 705 storage for scaled <a href="#Point">Point</a></td> 706 </tr> 707 </table> 708 709 ### Example 710 711 <div><fiddle-embed name="972e4e230806281adb928e068bcd8551"></fiddle-embed></div> 712 713 ### See Also 714 715 <a href="#SkPoint_multiply_operator">operator*(SkScalar scale) const</a> <a href="#SkPoint_multiplyby_operator">operator*=(SkScalar scale)</a> <a href="#SkPoint_setLength">setLength</a><sup><a href="#SkPoint_setLength_2">[2]</a></sup> 716 717 --- 718 719 <a name="SkPoint_scale_2"></a> 720 721 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 722 void scale(SkScalar value) 723 </pre> 724 725 Scales <a href="#Point">Point</a> in place by scale. 726 727 ### Parameters 728 729 <table> <tr> <td><a name="SkPoint_scale_2_value"> <code><strong>value </strong></code> </a></td> <td> 730 factor to multiply <a href="#Point">Point</a> by</td> 731 </tr> 732 </table> 733 734 ### Example 735 736 <div><fiddle-embed name="1060a4f27d8ef29519e6ac006ce90f2b"></fiddle-embed></div> 737 738 ### See Also 739 740 <a href="#SkPoint_multiply_operator">operator*(SkScalar scale) const</a> <a href="#SkPoint_multiplyby_operator">operator*=(SkScalar scale)</a> <a href="#SkPoint_setLength">setLength</a><sup><a href="#SkPoint_setLength_2">[2]</a></sup> 741 742 --- 743 744 <a name="SkPoint_negate"></a> 745 ## negate 746 747 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 748 void negate() 749 </pre> 750 751 Changes the sign of <a href="#SkPoint_fX">fX</a> and <a href="#SkPoint_fY">fY</a>. 752 753 ### Example 754 755 <div><fiddle-embed name="312c0c8065ab5d0adfda80cccf2d11e6"> 756 757 #### Example Output 758 759 ~~~~ 760 pt: 0, -0 negate: -0, 0 761 pt: -1, -2 negate: 1, 2 762 pt: inf, -inf negate: -inf, inf 763 pt: nan, -nan negate: -nan, nan 764 ~~~~ 765 766 </fiddle-embed></div> 767 768 ### See Also 769 770 <a href="#SkPoint_minus_operator">operator-() const</a> <a href="#SkPoint_setAbs">setAbs</a> 771 772 --- 773 774 <a name="SkPoint_minus_operator"></a> 775 ## operator- 776 777 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 778 SkPoint operator-() _const 779 </pre> 780 781 Returns <a href="#Point">Point</a> changing the signs of <a href="#SkPoint_fX">fX</a> and <a href="#SkPoint_fY">fY</a>. 782 783 ### Return Value 784 785 <a href="#Point">Point</a> as (-<a href="#SkPoint_fX">fX</a>, -<a href="#SkPoint_fY">fY</a>) 786 787 ### Example 788 789 <div><fiddle-embed name="9baf247cfcd8272c0ddf6ce93f676b37"> 790 791 #### Example Output 792 793 ~~~~ 794 pt: 0, -0 negate: -0, 0 795 pt: -1, -2 negate: 1, 2 796 pt: inf, -inf negate: -inf, inf 797 pt: nan, -nan negate: -nan, nan 798 ~~~~ 799 800 </fiddle-embed></div> 801 802 ### See Also 803 804 <a href="#SkPoint_negate">negate</a> <a href="#SkPoint_subtract_operator">operator-(const SkPoint& a, const SkPoint& b)</a> <a href="#SkPoint_subtractfrom_operator">operator-=(const SkVector& v)</a> <a href="SkIPoint_Reference#SkIPoint_minus_operator">SkIPoint::operator-() const</a> 805 806 --- 807 808 <a name="SkPoint_addto_operator"></a> 809 ## operator+= 810 811 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 812 void operator+=(const SkVector& v) 813 </pre> 814 815 Adds <a href="#Vector">Vector</a> <a href="#SkPoint_addto_operator_v">v</a> to <a href="#Point">Point</a>. Sets <a href="#Point">Point</a> to: 816 (<a href="#SkPoint_fX">fX</a> + <a href="#SkPoint_addto_operator_v">v</a>.<a href="#SkPoint_fX">fX</a>, <a href="#SkPoint_fY">fY</a> + <a href="#SkPoint_addto_operator_v">v</a>.<a href="#SkPoint_fY">fY</a>). 817 818 ### Parameters 819 820 <table> <tr> <td><a name="SkPoint_addto_operator_v"> <code><strong>v </strong></code> </a></td> <td> 821 <a href="#Vector">Vector</a> to add</td> 822 </tr> 823 </table> 824 825 ### Example 826 827 <div><fiddle-embed name="8b4e79109e2381345258cb744881b20c"></fiddle-embed></div> 828 829 ### See Also 830 831 <a href="#SkPoint_offset">offset</a> <a href="#SkPoint_add_operator">operator+(const SkPoint& a, const SkVector& b)</a> <a href="SkIPoint_Reference#SkIPoint_addto_operator">SkIPoint::operator+=(const SkIVector& v)</a> 832 833 --- 834 835 <a name="SkPoint_subtractfrom_operator"></a> 836 ## operator-= 837 838 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 839 void operator-=(const SkVector& v) 840 </pre> 841 842 Subtracts <a href="#Vector">Vector</a> <a href="#SkPoint_subtractfrom_operator_v">v</a> from <a href="#Point">Point</a>. Sets <a href="#Point">Point</a> to: 843 (<a href="#SkPoint_fX">fX</a> - <a href="#SkPoint_subtractfrom_operator_v">v</a>.<a href="#SkPoint_fX">fX</a>, <a href="#SkPoint_fY">fY</a> - <a href="#SkPoint_subtractfrom_operator_v">v</a>.<a href="#SkPoint_fY">fY</a>). 844 845 ### Parameters 846 847 <table> <tr> <td><a name="SkPoint_subtractfrom_operator_v"> <code><strong>v </strong></code> </a></td> <td> 848 <a href="#Vector">Vector</a> to subtract</td> 849 </tr> 850 </table> 851 852 ### Example 853 854 <div><fiddle-embed name="86c0399704d8dff4091bf87b8d87d40b"></fiddle-embed></div> 855 856 ### See Also 857 858 <a href="#SkPoint_offset">offset</a> <a href="#SkPoint_subtract_operator">operator-(const SkPoint& a, const SkPoint& b)</a> <a href="SkIPoint_Reference#SkIPoint_subtractfrom_operator">SkIPoint::operator-=(const SkIVector& v)</a> 859 860 --- 861 862 <a name="SkPoint_multiply_operator"></a> 863 ## operator* 864 865 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 866 SkPoint operator*(SkScalar scale) _const 867 </pre> 868 869 Returns <a href="#Point">Point</a> multiplied by scale. 870 871 ### Parameters 872 873 <table> <tr> <td><a name="SkPoint_multiply_operator_scale"> <code><strong>scale </strong></code> </a></td> <td> 874 <a href="undocumented#Scalar">Scalar</a> to multiply by</td> 875 </tr> 876 </table> 877 878 ### Return Value 879 880 <a href="#Point">Point</a> as (<a href="#SkPoint_fX">fX</a> * scale, <a href="#SkPoint_fY">fY</a> * scale) 881 882 ### Example 883 884 <div><fiddle-embed name="35b3bc675779de043706ae4817ee950c"></fiddle-embed></div> 885 886 ### See Also 887 888 <a href="#SkPoint_multiplyby_operator">operator*=(SkScalar scale)</a> <a href="#SkPoint_scale">scale</a><sup><a href="#SkPoint_scale_2">[2]</a></sup> <a href="#SkPoint_setLength">setLength</a><sup><a href="#SkPoint_setLength_2">[2]</a></sup> <a href="#SkPoint_setNormalize">setNormalize</a> 889 890 --- 891 892 <a name="SkPoint_multiplyby_operator"></a> 893 ## operator*= 894 895 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 896 SkPoint& operator*=(SkScalar scale) 897 </pre> 898 899 Multiplies <a href="#Point">Point</a> by scale. Sets <a href="#Point">Point</a> to: 900 (<a href="#SkPoint_fX">fX</a> * scale, <a href="#SkPoint_fY">fY</a> * scale) 901 902 ### Parameters 903 904 <table> <tr> <td><a name="SkPoint_multiplyby_operator_scale"> <code><strong>scale </strong></code> </a></td> <td> 905 <a href="undocumented#Scalar">Scalar</a> to multiply by</td> 906 </tr> 907 </table> 908 909 ### Return Value 910 911 reference to <a href="#Point">Point</a> 912 913 ### Example 914 915 <div><fiddle-embed name="3ce3db36235d80dbac4d39504cf756da"></fiddle-embed></div> 916 917 ### See Also 918 919 <a href="#SkPoint_multiply_operator">operator*(SkScalar scale) const</a> <a href="#SkPoint_scale">scale</a><sup><a href="#SkPoint_scale_2">[2]</a></sup> <a href="#SkPoint_setLength">setLength</a><sup><a href="#SkPoint_setLength_2">[2]</a></sup> <a href="#SkPoint_setNormalize">setNormalize</a> 920 921 --- 922 923 <a name="SkPoint_isFinite"></a> 924 ## isFinite 925 926 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 927 bool isFinite() const 928 </pre> 929 930 Returns true if both <a href="#SkPoint_fX">fX</a> and <a href="#SkPoint_fY">fY</a> are measurable values. 931 932 ### Return Value 933 934 true for values other than infinities and NaN 935 936 ### Example 937 938 <div><fiddle-embed name="937cc166cc0e220f33fb82501141d0b3"> 939 940 #### Example Output 941 942 ~~~~ 943 pt: 0, -0 finite: true 944 pt: -1, -2 finite: true 945 pt: inf, 1 finite: false 946 pt: nan, -1 finite: false 947 ~~~~ 948 949 </fiddle-embed></div> 950 951 ### See Also 952 953 <a href="SkRect_Reference#SkRect_isFinite">SkRect::isFinite</a> <a href="SkPath_Reference#SkPath_isFinite">SkPath::isFinite</a> 954 955 --- 956 957 <a name="SkPoint_equals"></a> 958 ## equals 959 960 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 961 bool equals(SkScalar x, SkScalar y) const 962 </pre> 963 964 Returns true if <a href="#Point">Point</a> is equivalent to <a href="#Point">Point</a> constructed from (x, y). 965 966 ### Parameters 967 968 <table> <tr> <td><a name="SkPoint_equals_x"> <code><strong>x </strong></code> </a></td> <td> 969 value compared with <a href="#SkPoint_fX">fX</a></td> 970 </tr> <tr> <td><a name="SkPoint_equals_y"> <code><strong>y </strong></code> </a></td> <td> 971 value compared with <a href="#SkPoint_fY">fY</a></td> 972 </tr> 973 </table> 974 975 ### Return Value 976 977 true if <a href="#Point">Point</a> equals (x, y) 978 979 ### Example 980 981 <div><fiddle-embed name="4cecb878c8b66beffda051f26c00f817"> 982 983 #### Example Output 984 985 ~~~~ 986 pt: 0, -0 == pt 987 pt: -1, -2 == pt 988 pt: inf, 1 == pt 989 pt: nan, -1 != pt 990 ~~~~ 991 992 </fiddle-embed></div> 993 994 ### See Also 995 996 <a href="#SkPoint_equal_operator">operator==(const SkPoint& a, const SkPoint& b)</a> 997 998 --- 999 1000 <a name="SkPoint_equal_operator"></a> 1001 ## operator== 1002 1003 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1004 bool operator==(const SkPoint& a, const SkPoint& b) 1005 </pre> 1006 1007 Returns true if <a href="#SkPoint_equal_operator_a">a</a> is equivalent to <a href="#SkPoint_equal_operator_b">b</a>. 1008 1009 ### Parameters 1010 1011 <table> <tr> <td><a name="SkPoint_equal_operator_a"> <code><strong>a </strong></code> </a></td> <td> 1012 <a href="#Point">Point</a> to compare</td> 1013 </tr> <tr> <td><a name="SkPoint_equal_operator_b"> <code><strong>b </strong></code> </a></td> <td> 1014 <a href="#Point">Point</a> to compare</td> 1015 </tr> 1016 </table> 1017 1018 ### Return Value 1019 1020 true if <a href="#SkPoint_equal_operator_a">a</a>.<a href="#SkPoint_fX">fX</a> == <a href="#SkPoint_equal_operator_b">b</a>.<a href="#SkPoint_fX">fX</a> and <a href="#SkPoint_equal_operator_a">a</a>.<a href="#SkPoint_fY">fY</a> == <a href="#SkPoint_equal_operator_b">b</a>.<a href="#SkPoint_fY">fY</a> 1021 1022 ### Example 1023 1024 <div><fiddle-embed name="741f793334a48a35dadf4310d7ea52cb"> 1025 1026 #### Example Output 1027 1028 ~~~~ 1029 pt: 0, -0 == pt 1030 pt: -1, -2 == pt 1031 pt: inf, 1 == pt 1032 pt: nan, -1 != pt 1033 ~~~~ 1034 1035 </fiddle-embed></div> 1036 1037 ### See Also 1038 1039 <a href="#SkPoint_equals">equals</a> <a href="#SkPoint_notequal_operator">operator!=(const SkPoint& a, const SkPoint& b)</a> 1040 1041 --- 1042 1043 <a name="SkPoint_notequal_operator"></a> 1044 ## operator!= 1045 1046 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1047 bool operator!=(const SkPoint& a, const SkPoint& b) 1048 </pre> 1049 1050 Returns true if <a href="#SkPoint_notequal_operator_a">a</a> is not equivalent to <a href="#SkPoint_notequal_operator_b">b</a>. 1051 1052 ### Parameters 1053 1054 <table> <tr> <td><a name="SkPoint_notequal_operator_a"> <code><strong>a </strong></code> </a></td> <td> 1055 <a href="#Point">Point</a> to compare</td> 1056 </tr> <tr> <td><a name="SkPoint_notequal_operator_b"> <code><strong>b </strong></code> </a></td> <td> 1057 <a href="#Point">Point</a> to compare</td> 1058 </tr> 1059 </table> 1060 1061 ### Return Value 1062 1063 true if <a href="#SkPoint_notequal_operator_a">a</a>.<a href="#SkPoint_fX">fX</a> != <a href="#SkPoint_notequal_operator_b">b</a>.<a href="#SkPoint_fX">fX</a> or <a href="#SkPoint_notequal_operator_a">a</a>.<a href="#SkPoint_fY">fY</a> != <a href="#SkPoint_notequal_operator_b">b</a>.<a href="#SkPoint_fY">fY</a> 1064 1065 ### Example 1066 1067 <div><fiddle-embed name="8fe8572685eaa617f25a5a6767a874dc"> 1068 1069 #### Example Output 1070 1071 ~~~~ 1072 pt: 0, -0 == pt 1073 pt: -1, -2 == pt 1074 pt: inf, 1 == pt 1075 pt: nan, -1 != pt 1076 ~~~~ 1077 1078 </fiddle-embed></div> 1079 1080 ### See Also 1081 1082 <a href="#SkPoint_equal_operator">operator==(const SkPoint& a, const SkPoint& b)</a> <a href="#SkPoint_equals">equals</a> 1083 1084 --- 1085 1086 <a name="SkPoint_subtract_operator"></a> 1087 ## operator- 1088 1089 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1090 SkVector operator-(const SkPoint& a, const SkPoint& b) 1091 </pre> 1092 1093 Returns <a href="#Vector">Vector</a> from <a href="#SkPoint_subtract_operator_b">b</a> to <a href="#SkPoint_subtract_operator_a">a</a>, computed as(<a href="#SkPoint_subtract_operator_a">a</a>.<a href="#SkPoint_fX">fX</a> - <a href="#SkPoint_subtract_operator_b">b</a>.<a href="#SkPoint_fX">fX</a>, <a href="#SkPoint_subtract_operator_a">a</a>.<a href="#SkPoint_fY">fY</a> - <a href="#SkPoint_subtract_operator_b">b</a>.<a href="#SkPoint_fY">fY</a>). 1094 1095 Can also be used to subtract <a href="#Vector">Vector</a> from <a href="#Point">Point</a>, returning <a href="#Point">Point</a>. 1096 Can also be used to subtract <a href="#Vector">Vector</a> from <a href="#Vector">Vector</a>, returning <a href="#Vector">Vector</a>. 1097 1098 ### Parameters 1099 1100 <table> <tr> <td><a name="SkPoint_subtract_operator_a"> <code><strong>a </strong></code> </a></td> <td> 1101 <a href="#Point">Point</a> to subtract from</td> 1102 </tr> <tr> <td><a name="SkPoint_subtract_operator_b"> <code><strong>b </strong></code> </a></td> <td> 1103 <a href="#Point">Point</a> to subtract</td> 1104 </tr> 1105 </table> 1106 1107 ### Return Value 1108 1109 <a href="#Vector">Vector</a> from <a href="#SkPoint_subtract_operator_b">b</a> to <a href="#SkPoint_subtract_operator_a">a</a> 1110 1111 ### Example 1112 1113 <div><fiddle-embed name="b6c4943ecd0b2dccf9d220b8944009e0"></fiddle-embed></div> 1114 1115 ### See Also 1116 1117 <a href="#SkPoint_subtractfrom_operator">operator-=(const SkVector& v)</a> <a href="#SkPoint_offset">offset</a> 1118 1119 --- 1120 1121 <a name="SkPoint_add_operator"></a> 1122 ## operator+ 1123 1124 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1125 SkPoint operator+(const SkPoint& a, const SkVector& b) 1126 </pre> 1127 1128 Returns <a href="#Point">Point</a> resulting from <a href="#Point">Point</a> <a href="#SkPoint_add_operator_a">a</a> offset by <a href="#Vector">Vector</a> <a href="#SkPoint_add_operator_b">b</a>, computed as: 1129 (<a href="#SkPoint_add_operator_a">a</a>.<a href="#SkPoint_fX">fX</a> + <a href="#SkPoint_add_operator_b">b</a>.<a href="#SkPoint_fX">fX</a>, <a href="#SkPoint_add_operator_a">a</a>.<a href="#SkPoint_fY">fY</a> + <a href="#SkPoint_add_operator_b">b</a>.<a href="#SkPoint_fY">fY</a>). 1130 1131 Can also be used to offset <a href="#Point">Point</a> <a href="#SkPoint_add_operator_b">b</a> by <a href="#Vector">Vector</a> <a href="#SkPoint_add_operator_a">a</a>, returning <a href="#Point">Point</a>. 1132 Can also be used to add <a href="#Vector">Vector</a> to <a href="#Vector">Vector</a>, returning <a href="#Vector">Vector</a>. 1133 1134 ### Parameters 1135 1136 <table> <tr> <td><a name="SkPoint_add_operator_a"> <code><strong>a </strong></code> </a></td> <td> 1137 <a href="#Point">Point</a> or <a href="#Vector">Vector</a> to add to</td> 1138 </tr> <tr> <td><a name="SkPoint_add_operator_b"> <code><strong>b </strong></code> </a></td> <td> 1139 <a href="#Point">Point</a> or <a href="#Vector">Vector</a> to add</td> 1140 </tr> 1141 </table> 1142 1143 ### Return Value 1144 1145 <a href="#Point">Point</a> equal to <a href="#SkPoint_add_operator_a">a</a> offset by <a href="#SkPoint_add_operator_b">b</a> 1146 1147 ### Example 1148 1149 <div><fiddle-embed name="911a84253dfec4dabf94dbe3c71766f0"></fiddle-embed></div> 1150 1151 ### See Also 1152 1153 <a href="#SkPoint_addto_operator">operator+=(const SkVector& v)</a> <a href="#SkPoint_offset">offset</a> 1154 1155 --- 1156 1157 <a name="SkPoint_Length"></a> 1158 ## Length 1159 1160 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1161 static SkScalar Length(SkScalar x, SkScalar y) 1162 </pre> 1163 1164 Returns the Euclidean_Distance from origin, computed as: 1165 1166 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1167 sqrt(x * x + y * y)</pre> 1168 1169 . 1170 1171 ### Parameters 1172 1173 <table> <tr> <td><a name="SkPoint_Length_x"> <code><strong>x </strong></code> </a></td> <td> 1174 component of length</td> 1175 </tr> <tr> <td><a name="SkPoint_Length_y"> <code><strong>y </strong></code> </a></td> <td> 1176 component of length</td> 1177 </tr> 1178 </table> 1179 1180 ### Return Value 1181 1182 straight-line distance to origin 1183 1184 ### Example 1185 1186 <div><fiddle-embed name="c98773d8b4509969d78cb8121e4b77f6"></fiddle-embed></div> 1187 1188 ### See Also 1189 1190 <a href="#SkPoint_length">length</a> <a href="#SkPoint_Distance">Distance</a> <a href="#SkPoint_setLength">setLength</a><sup><a href="#SkPoint_setLength_2">[2]</a></sup> 1191 1192 --- 1193 1194 <a name="SkPoint_Normalize"></a> 1195 ## Normalize 1196 1197 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1198 static SkScalar Normalize(SkVector* vec) 1199 </pre> 1200 1201 Scales (<a href="#SkPoint_Normalize_vec">vec</a>-><a href="#SkPoint_fX">fX</a>, <a href="#SkPoint_Normalize_vec">vec</a>-><a href="#SkPoint_fY">fY</a>) so that <a href="#SkPoint_length">length</a> returns one, while preserving ratio of <a href="#SkPoint_Normalize_vec">vec</a>-><a href="#SkPoint_fX">fX</a> to <a href="#SkPoint_Normalize_vec">vec</a>-><a href="#SkPoint_fY">fY</a>, 1202 if possible. If original length is nearly zero, sets <a href="#SkPoint_Normalize_vec">vec</a> to (0, 0) and returns zero; 1203 otherwise, returns length of <a href="#SkPoint_Normalize_vec">vec</a> before <a href="#SkPoint_Normalize_vec">vec</a> is scaled. 1204 1205 Returned prior length may be <a href="undocumented#SK_ScalarInfinity">SK ScalarInfinity</a> if it can not be represented by <a href="undocumented#SkScalar">SkScalar</a>. 1206 1207 Note that <a href="#SkPoint_normalize">normalize</a> is faster if prior length is not required. 1208 1209 ### Parameters 1210 1211 <table> <tr> <td><a name="SkPoint_Normalize_vec"> <code><strong>vec </strong></code> </a></td> <td> 1212 normalized to unit length</td> 1213 </tr> 1214 </table> 1215 1216 ### Return Value 1217 1218 original <a href="#SkPoint_Normalize_vec">vec</a> length 1219 1220 ### Example 1221 1222 <div><fiddle-embed name="60a08f3ce75374fc815384616d114df7"></fiddle-embed></div> 1223 1224 ### See Also 1225 1226 <a href="#SkPoint_normalize">normalize</a> <a href="#SkPoint_setLength">setLength</a><sup><a href="#SkPoint_setLength_2">[2]</a></sup> <a href="#SkPoint_Length">Length</a> 1227 1228 --- 1229 1230 <a name="SkPoint_Distance"></a> 1231 ## Distance 1232 1233 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1234 static SkScalar Distance(const SkPoint& a, const SkPoint& b) 1235 </pre> 1236 1237 Returns the Euclidean_Distance between <a href="#SkPoint_Distance_a">a</a> and <a href="#SkPoint_Distance_b">b</a>. 1238 1239 ### Parameters 1240 1241 <table> <tr> <td><a name="SkPoint_Distance_a"> <code><strong>a </strong></code> </a></td> <td> 1242 line end point</td> 1243 </tr> <tr> <td><a name="SkPoint_Distance_b"> <code><strong>b </strong></code> </a></td> <td> 1244 line end point</td> 1245 </tr> 1246 </table> 1247 1248 ### Return Value 1249 1250 straight-line distance from <a href="#SkPoint_Distance_a">a</a> to <a href="#SkPoint_Distance_b">b</a> 1251 1252 ### Example 1253 1254 <div><fiddle-embed name="9e0a2de2eb94dba4521d733e73f2bda5"></fiddle-embed></div> 1255 1256 ### See Also 1257 1258 <a href="#SkPoint_length">length</a> <a href="#SkPoint_setLength">setLength</a><sup><a href="#SkPoint_setLength_2">[2]</a></sup> 1259 1260 --- 1261 1262 <a name="SkPoint_DotProduct"></a> 1263 ## DotProduct 1264 1265 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1266 static SkScalar DotProduct(const SkVector& a, const SkVector& b) 1267 </pre> 1268 1269 Returns the dot product of <a href="#Vector">Vector</a> <a href="#SkPoint_DotProduct_a">a</a> and <a href="#Vector">Vector</a> <a href="#SkPoint_DotProduct_b">b</a>. 1270 1271 ### Parameters 1272 1273 <table> <tr> <td><a name="SkPoint_DotProduct_a"> <code><strong>a </strong></code> </a></td> <td> 1274 left side of dot product</td> 1275 </tr> <tr> <td><a name="SkPoint_DotProduct_b"> <code><strong>b </strong></code> </a></td> <td> 1276 right side of dot product</td> 1277 </tr> 1278 </table> 1279 1280 ### Return Value 1281 1282 product of input magnitudes and cosine of the angle between them 1283 1284 ### Example 1285 1286 <div><fiddle-embed name="496db0131a003162faba7d7f98b30340"></fiddle-embed></div> 1287 1288 ### See Also 1289 1290 <a href="#SkPoint_dot">dot</a> <a href="#SkPoint_CrossProduct">CrossProduct</a> 1291 1292 --- 1293 1294 <a name="SkPoint_CrossProduct"></a> 1295 ## CrossProduct 1296 1297 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1298 static SkScalar CrossProduct(const SkVector& a, const SkVector& b) 1299 </pre> 1300 1301 Returns the cross product of <a href="#Vector">Vector</a> <a href="#SkPoint_CrossProduct_a">a</a> and <a href="#Vector">Vector</a> <a href="#SkPoint_CrossProduct_b">b</a>. 1302 1303 <a href="#SkPoint_CrossProduct_a">a</a> and <a href="#SkPoint_CrossProduct_b">b</a> form three-dimensional vectors with z-axis value equal to zero. The 1304 cross product is <a href="#SkPoint_CrossProduct_a">a</a> three-dimensional vector with x-axis and y-axis values equal 1305 to zero. The cross product z-axis component is returned. 1306 1307 ### Parameters 1308 1309 <table> <tr> <td><a name="SkPoint_CrossProduct_a"> <code><strong>a </strong></code> </a></td> <td> 1310 left side of cross product</td> 1311 </tr> <tr> <td><a name="SkPoint_CrossProduct_b"> <code><strong>b </strong></code> </a></td> <td> 1312 right side of cross product</td> 1313 </tr> 1314 </table> 1315 1316 ### Return Value 1317 1318 area spanned by <a href="#Vector">Vectors</a> signed by angle direction 1319 1320 ### Example 1321 1322 <div><fiddle-embed name="8b8a4cd8a29d22bb9c5e63b70357bd65"></fiddle-embed></div> 1323 1324 ### See Also 1325 1326 <a href="#SkPoint_cross">cross</a> <a href="#SkPoint_DotProduct">DotProduct</a> 1327 1328 --- 1329 1330 <a name="SkPoint_cross"></a> 1331 ## cross 1332 1333 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1334 SkScalar cross(const SkVector& vec) const 1335 </pre> 1336 1337 Returns the cross product of <a href="#Vector">Vector</a> and <a href="#SkPoint_cross_vec">vec</a>. 1338 1339 <a href="#Vector">Vector</a> and <a href="#SkPoint_cross_vec">vec</a> form three-dimensional vectors with z-axis value equal to zero. 1340 The cross product is a three-dimensional vector with x-axis and y-axis values 1341 equal to zero. The cross product z-axis component is returned. 1342 1343 ### Parameters 1344 1345 <table> <tr> <td><a name="SkPoint_cross_vec"> <code><strong>vec </strong></code> </a></td> <td> 1346 right side of cross product</td> 1347 </tr> 1348 </table> 1349 1350 ### Return Value 1351 1352 area spanned by <a href="#Vector">Vectors</a> signed by angle direction 1353 1354 ### Example 1355 1356 <div><fiddle-embed name="0bc7b3997357e499817278b78bdfbf1d"></fiddle-embed></div> 1357 1358 ### See Also 1359 1360 <a href="#SkPoint_CrossProduct">CrossProduct</a> <a href="#SkPoint_dot">dot</a> 1361 1362 --- 1363 1364 <a name="SkPoint_dot"></a> 1365 ## dot 1366 1367 <pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1368 SkScalar dot(const SkVector& vec) const 1369 </pre> 1370 1371 Returns the dot product of <a href="#Vector">Vector</a> and <a href="#Vector">Vector</a> <a href="#SkPoint_dot_vec">vec</a>. 1372 1373 ### Parameters 1374 1375 <table> <tr> <td><a name="SkPoint_dot_vec"> <code><strong>vec </strong></code> </a></td> <td> 1376 right side of dot product</td> 1377 </tr> 1378 </table> 1379 1380 ### Return Value 1381 1382 product of input magnitudes and cosine of the angle between them 1383 1384 ### Example 1385 1386 <div><fiddle-embed name="56d01ccfedd71d3c504b09afa2875d38"></fiddle-embed></div> 1387 1388 ### See Also 1389 1390 <a href="#SkPoint_DotProduct">DotProduct</a> <a href="#SkPoint_cross">cross</a> 1391 1392 --- 1393 1394 # <a name="Vector"></a> Vector 1395