{"id":2830,"date":"2023-07-20T12:26:30","date_gmt":"2023-07-20T12:26:30","guid":{"rendered":"https:\/\/statorials.org\/nl\/cross-python-product\/"},"modified":"2023-07-20T12:26:30","modified_gmt":"2023-07-20T12:26:30","slug":"cross-python-product","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/cross-python-product\/","title":{"rendered":"Hoe een kruisproduct in python te berekenen"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Ervan uitgaande dat we vector A hebben met elementen (A <sub>1<\/sub> , A <sub>2<\/sub> , A <sub>3<\/sub> ) en vector B met elementen (B <sub>1<\/sub> , B <sub>2<\/sub> , B <sub>3<\/sub> ), kunnen we het kruisproduct van deze twee vectoren als volgt berekenen:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Kruisproduct<\/strong> = [(A <sub>2<\/sub> *B <sub>3<\/sub> ) \u2013 (A <sub>3<\/sub> *B <sub>2<\/sub> ), (A <sub>3<\/sub> *B <sub>1<\/sub> ) \u2013 (A <sub>1<\/sub> *B <sub>3<\/sub> ), (A <sub>1<\/sub> *B <sub>2<\/sub> ) \u2013 (A <sub>2<\/sub> *B <sub>1<\/sub> )]<\/span><\/p>\n<p> <span style=\"color: #000000;\">Stel dat we bijvoorbeeld de volgende vectoren hebben:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Vector A: (1, 2, 3)<\/span><\/li>\n<li> <span style=\"color: #000000;\">Vector B: (4, 5, 6)<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">We kunnen het kruisproduct van deze vectoren als volgt berekenen:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Kruisproduct = [(A <sub>2<\/sub> *B <sub>3<\/sub> ) \u2013 (A <sub>3<\/sub> *B <sub>2<\/sub> ), (A <sub>3<\/sub> *B <sub>1<\/sub> ) \u2013 (A <sub>1<\/sub> *B <sub>3<\/sub> ), (A <sub>1<\/sub> *B <sub>2<\/sub> ) \u2013 (A <sub>2<\/sub> *B <sub>1<\/sub> )]<\/span><\/li>\n<li> <span style=\"color: #000000;\">Kruisproduct = [(2*6) \u2013 (3*5), (3*4) \u2013 (1*6), (1*5) \u2013 (2*4)]<\/span><\/li>\n<li> <span style=\"color: #000000;\">Kruisproduct = (-3, 6, -3)<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">U kunt een van de volgende twee methoden gebruiken om het kruisproduct van twee vectoren in Python te berekenen:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Methode 1: Gebruik de cross()-functie van NumPy<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n  \n<span style=\"color: #008080;\">#calculate cross product of vectors A and B\n<\/span>n.p. <span style=\"color: #3366ff;\">cross<\/span> (A, B)\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\"><strong>Methode 2: Definieer uw eigen functie<\/strong><\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define function to calculate cross product<\/span> \n<span style=\"color: #008000;\">def<\/span> <span style=\"color: #3366ff;\">cross_prod<\/span> (a,b):\n    result = [a[1] <span style=\"color: #800080;\">*<\/span> b[2] - a[2] <span style=\"color: #800080;\">*<\/span> b[1],\n            a[2] <span style=\"color: #800080;\">*<\/span> b[0] - a[0] <span style=\"color: #800080;\">*<\/span> b[2],\n            a[0] <span style=\"color: #800080;\">*<\/span> b[1] - a[1] <span style=\"color: #800080;\">*<\/span> b[0]]\n\n    <span style=\"color: #008000;\">return<\/span> result\n\n<span style=\"color: #008080;\">#calculate cross product\n<\/span>cross_prod(A, B)<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">De volgende voorbeelden laten zien hoe u elke methode in de praktijk kunt gebruiken.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Voorbeeld 1: gebruik van de NumPy cross()-functie<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe u de functie <a href=\"https:\/\/numpy.org\/doc\/stable\/reference\/generated\/numpy.cross.html\" target=\"_blank\" rel=\"noopener\">cross()<\/a> van NumPy gebruikt om het kruisproduct tussen twee vectoren te berekenen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\">#definevectors<\/span>\nA = np. <span style=\"color: #3366ff;\">array<\/span> ([1, 2, 3])\nB = np. <span style=\"color: #3366ff;\">array<\/span> ([4, 5, 6])\n  \n<span style=\"color: #008080;\">#calculate cross product of vectors A and B\n<\/span>n.p. <span style=\"color: #3366ff;\">cross<\/span> (A, B)\n\n[-3, 6, -3]\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Het kruisproduct blijkt <strong>(-3, 6, -3)<\/strong> te zijn.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dit komt overeen met het kruisproduct dat we eerder handmatig hebben berekend.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Voorbeeld 2: Definieer uw eigen functie<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">De volgende code laat zien hoe u uw eigen functie definieert om het kruisproduct tussen twee vectoren te berekenen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define function to calculate cross product<\/span> \n<span style=\"color: #008000;\">def<\/span> <span style=\"color: #3366ff;\">cross_prod<\/span> (a,b):\n    result = [a[1] <span style=\"color: #800080;\">*<\/span> b[2] - a[2] <span style=\"color: #800080;\">*<\/span> b[1],\n            a[2] <span style=\"color: #800080;\">*<\/span> b[0] - a[0] <span style=\"color: #800080;\">*<\/span> b[2],\n            a[0] <span style=\"color: #800080;\">*<\/span> b[1] - a[1] <span style=\"color: #800080;\">*<\/span> b[0]]\n\n    <span style=\"color: #008000;\">return<\/span> result\n\n<span style=\"color: #008080;\">#definevectors<\/span>\nA = np. <span style=\"color: #3366ff;\">array<\/span> ([1, 2, 3])\nB = np. <span style=\"color: #3366ff;\">array<\/span> ([4, 5, 6])\n\n<span style=\"color: #008080;\">#calculate cross product\n<\/span>cross_prod(A, B)\n\n[-3, 6, -3]\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Het kruisproduct blijkt <strong>(-3, 6, -3)<\/strong> te zijn.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dit komt overeen met het kruisproduct dat we in het vorige voorbeeld hebben berekend.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">In de volgende tutorials wordt uitgelegd hoe u andere veelvoorkomende taken in Python kunt uitvoeren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/numpy-dot-product\/\" target=\"_blank\" rel=\"noopener\">Hoe een puntproduct te berekenen met NumPy<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/numpy-normalisatiematrix\/\" target=\"_blank\" rel=\"noopener\">Hoe een NumPy-matrix te normaliseren<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/numpy-voeg-een-rij-toe-aan-de-matrix\/\" target=\"_blank\" rel=\"noopener\">Hoe rij aan matrix toe te voegen in NumPy<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ervan uitgaande dat we vector A hebben met elementen (A 1 , A 2 , A 3 ) en vector B met elementen (B 1 , B 2 , B 3 ), kunnen we het kruisproduct van deze twee vectoren als volgt berekenen: Kruisproduct = [(A 2 *B 3 ) \u2013 (A 3 *B 2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-2830","post","type-post","status-publish","format-standard","hentry","category-gids"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hoe een kruisproduct in Python te berekenen - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt met voorbeelden uitgelegd hoe je het kruisproduct tussen twee vectoren in Python kunt berekenen.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/nl\/cross-python-product\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe een kruisproduct in Python te berekenen - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt met voorbeelden uitgelegd hoe je het kruisproduct tussen twee vectoren in Python kunt berekenen.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/cross-python-product\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-20T12:26:30+00:00\" \/>\n<meta name=\"author\" content=\"Dr.benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr.benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/cross-python-product\/\",\"url\":\"https:\/\/statorials.org\/nl\/cross-python-product\/\",\"name\":\"Hoe een kruisproduct in Python te berekenen - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-20T12:26:30+00:00\",\"dateModified\":\"2023-07-20T12:26:30+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt met voorbeelden uitgelegd hoe je het kruisproduct tussen twee vectoren in Python kunt berekenen.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/cross-python-product\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/cross-python-product\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/cross-python-product\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe een kruisproduct in python te berekenen\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/nl\/#website\",\"url\":\"https:\/\/statorials.org\/nl\/\",\"name\":\"Statorials\",\"description\":\"Uw gids voor statistische competentie\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/nl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\",\"name\":\"Dr.benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr.benjamin anderson\"},\"description\":\"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder\",\"sameAs\":[\"http:\/\/statorials.org\/nl\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hoe een kruisproduct in Python te berekenen - Statorials","description":"In deze tutorial wordt met voorbeelden uitgelegd hoe je het kruisproduct tussen twee vectoren in Python kunt berekenen.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/nl\/cross-python-product\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe een kruisproduct in Python te berekenen - Statorials","og_description":"In deze tutorial wordt met voorbeelden uitgelegd hoe je het kruisproduct tussen twee vectoren in Python kunt berekenen.","og_url":"https:\/\/statorials.org\/nl\/cross-python-product\/","og_site_name":"Statorials","article_published_time":"2023-07-20T12:26:30+00:00","author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/cross-python-product\/","url":"https:\/\/statorials.org\/nl\/cross-python-product\/","name":"Hoe een kruisproduct in Python te berekenen - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-20T12:26:30+00:00","dateModified":"2023-07-20T12:26:30+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt met voorbeelden uitgelegd hoe je het kruisproduct tussen twee vectoren in Python kunt berekenen.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/cross-python-product\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/cross-python-product\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/cross-python-product\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe een kruisproduct in python te berekenen"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/nl\/#website","url":"https:\/\/statorials.org\/nl\/","name":"Statorials","description":"Uw gids voor statistische competentie","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/nl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219","name":"Dr.benjamin anderson","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/","url":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr.benjamin anderson"},"description":"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder","sameAs":["http:\/\/statorials.org\/nl"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/2830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/comments?post=2830"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/2830\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=2830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=2830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=2830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}