{"id":308,"date":"2011-06-10T16:21:15","date_gmt":"2011-06-10T16:21:15","guid":{"rendered":"http:\/\/devnot.wordpress.com\/?p=308"},"modified":"2011-06-10T16:21:15","modified_gmt":"2011-06-10T16:21:15","slug":"get-a-offset-or-point-on-a-vector-perpendicular-to-a-point","status":"publish","type":"post","link":"https:\/\/thomas-jansen.eu\/?p=308","title":{"rendered":"Get a offset (or point) on a vector perpendicular to a point"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>To find the offset on a vector perpendicular to a point use the dot product<\/p>\n<p>Assume the vector is defined by P1 and P2\u00a0 and the point by P<\/p>\n<p>in 2d<\/p>\n<pre>            (P.x - P1.x) * (P2.x - P1.x) + (P.y - P1.y) * (P2.y - P1.y)\noffset =\u00a0\u00a0\u00a0 -----------------------------------------------------------------\n            (P2.x - P1.x) * (P2.x - P1.x) + (P2.y - P1.y) * (P2.y - P1.y)<\/pre>\n<p>or 3d<\/p>\n<pre>            (P.x - P1.x) * (P2.x - P1.x) + (P.y - P1.y) * (P2.y - P1.y) + (P.z - P1.z) * (P2.z- P1.z)\noffset =\u00a0\u00a0\u00a0 ---------------------------------------------------------------------------------------------------\n            (P2.x - P1.x) * (P2.x - P1.x) + (P2.y - P1.y) * (P2.y - P1.y) + (P2.z - P1.z) * (P2.z - P1.z)<\/pre>\n<p><strong>notes:<\/strong><\/p>\n<p>If vector P1,P2 has been normalized (length 1) the division by the length is obviously not necessary. If not the result is divided the square length. Although divided by the length (square root) the result will equal that of a normalized vector. Keep in mind that the dot project is a projection on the vector thus requiring a additional division by the length!<\/p>\n<p>&nbsp;<\/p>\n<p>Calculating the point on the vector can be done using<\/p>\n<pre>P.x =\u00a0 P1.x + (P2.x - P1.x) * o;\n\nP.y =\u00a0 P1.y + (P2.y - P1.y) * o;\n\nP.z =\u00a0 P1.z + (P2.z - P1.z) * o;\u00a0 (3d)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; To find the offset on a vector perpendicular to a point use the dot product Assume the vector is defined by P1 and P2\u00a0 and the point by P in 2d (P.x &#8211; P1.x) * (P2.x &#8211; P1.x) + (P.y &#8211; P1.y) * (P2.y &#8211; P1.y) offset =\u00a0\u00a0\u00a0 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; (P2.x &#8211; P1.x) * (P2.x [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[50,55,56,82],"class_list":["post-308","post","type-post","status-publish","format-standard","hentry","category-geometry","tag-offset","tag-perpendicular","tag-point","tag-vector"],"_links":{"self":[{"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/posts\/308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=308"}],"version-history":[{"count":0,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=\/wp\/v2\/posts\/308\/revisions"}],"wp:attachment":[{"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thomas-jansen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}