vector normal */
| 1652 | |
| 1653 | /* vector normal */ |
| 1654 | static pointObj point_norm(const pointObj a) { |
| 1655 | double lenmul; |
| 1656 | pointObj retv; |
| 1657 | |
| 1658 | #ifdef USE_POINT_Z_M |
| 1659 | if (a.x==0 && a.y==0 && a.z==0 && a.m==0) |
| 1660 | #else |
| 1661 | if (a.x==0 && a.y==0) |
| 1662 | #endif |
| 1663 | return a; |
| 1664 | |
| 1665 | lenmul=1.0/sqrt(point_abs2(a)); /* this seems to be the costly operation */ |
| 1666 | |
| 1667 | retv.x = a.x*lenmul; |
| 1668 | retv.y = a.y*lenmul; |
| 1669 | #ifdef USE_POINT_Z_M |
| 1670 | retv.z = a.z*lenmul; |
| 1671 | retv.m = a.m*lenmul; |
| 1672 | #endif |
| 1673 | |
| 1674 | return retv; |
| 1675 | } |
| 1676 | |
| 1677 | /* rotate a vector 90 degrees */ |
| 1678 | static pointObj point_rotz90(const pointObj a) { |
no test coverage detected