{"id":1188,"date":"2016-07-14T19:32:20","date_gmt":"2016-07-14T16:32:20","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=1188"},"modified":"2016-09-02T15:36:32","modified_gmt":"2016-09-02T12:36:32","slug":"1188","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=1188","title":{"rendered":"\u0412\u0435\u043a\u0442\u043e\u0440\u044b"},"content":{"rendered":"<p><strong>\u0417\u0430\u0434\u0430\u0447\u0430.<\/strong> \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<br \/>\n<strong>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435.<\/strong> \u0412\u0435\u043a\u0442\u043e\u0440 &#8212; \u044d\u0442\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u0440\u0435\u0437\u043e\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0442\u0440\u0435\u0437\u043e\u043a, \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u0434\u043b\u0438\u043d\u0443 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u0413\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u043f\u0440\u044f\u043c\u043e\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b.<\/p>\n<h2>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b:<\/h2>\n<h2>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430:<\/h2>\n<pre class=\"lang:java decode:true \">class MyVector {\r\n\tprivate double x;\r\n\tprivate double y;\r\n\tpublic MyVector(double x, double y) {\r\n\t\tthis.x = x; \r\n\t\tthis.y = y;\r\n\t}\r\n\tpublic double vLength() {\r\n\t\tdouble tempLen =  Math.sqrt(x*x + y*y);\r\n\t\tdouble newLen = new BigDecimal(tempLen).setScale(3, RoundingMode.UP).doubleValue();\r\n\t\treturn newLen;\r\n\t}\r\n\tpublic static MyVector sum(MyVector a, MyVector b) {\r\n\t\treturn new MyVector(a.x + b.x, a.y + b.y);\r\n\t}\r\n\tpublic static MyVector sub(MyVector a, MyVector b) {\r\n\t\treturn new MyVector(a.x - b.x, a.y - b.y);\r\n\t}\r\n\tpublic static MyVector mul(MyVector a, double c) {\r\n\t\treturn new MyVector(a.x * c, a.y * c);\r\n\t}\r\n\tpublic static double scalar(MyVector a, MyVector b) {\r\n\t\tdouble tempScalar = a.x * b.x + a.y * b.y;\r\n\t\tdouble newScalar = new BigDecimal(tempScalar).setScale(3, RoundingMode.UP).doubleValue();\r\n\t\treturn newScalar;\r\n\t}\r\n\tpublic static double cos(MyVector a, MyVector b) {\r\n\t\tdouble tempCos = scalar(a, b) \/ (a.vLength() * b.vLength());\r\n\t\tdouble newCos = new BigDecimal(tempCos).setScale(3, RoundingMode.UP).doubleValue();\r\n\t\treturn newCos;\r\n\t}\r\n\tpublic static double projection(MyVector a, MyVector b) {\r\n\t\tdouble tempProj = scalar(a, b) \/ b.vLength();\r\n\t\tdouble newProj = new BigDecimal(tempProj).setScale(5, RoundingMode.UP).doubleValue();\r\n\t\treturn newProj;\r\n\t}\r\n\tpublic static boolean isCollinear(MyVector a, MyVector b) throws ArithmeticException {\r\n\t\tdouble eps = 0.0001;\r\n\t\tif (b.x == 0 || b.y == 0) {\r\n\t\t\tthrow new ArithmeticException(\"Zero divider\");\r\n\t\t}\r\n\t\treturn (Math.abs(a.x \/ b.x - a.y \/ b.y) &lt; eps);\r\n\t}\r\n\tpublic static double vecProduct(MyVector a, MyVector b) {\r\n\t\tdouble tempProduct = a.vLength() * b.vLength() * Math.sqrt(1 - cos(a,b) * cos(a,b));\r\n\t\tdouble newProduct = new BigDecimal(tempProduct).setScale(5, RoundingMode.UP).doubleValue();\r\n\t\treturn newProduct;\r\n\t}\r\n\tpublic String toString() {\r\n\t\treturn new String(x + &quot; ; &quot; + y);\r\n\t}\r\n}<\/pre>\n<h2>\u0424\u043e\u0440\u043c\u0443\u043b\u044b<\/h2>\n<p><strong>\u0414\u043b\u0438\u043d\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430<\/strong><br \/>\n[latex]|\\vec{a}| = \\sqrt{x^2+y^2}[\/latex]\n<p><strong>\u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043d\u0430 \u0447\u0438\u0441\u043b\u043e<\/strong><br \/>\n[latex]\\lambda \\vec{a} = \\left\\{ \\lambda x; \\lambda y \\right\\}[\/latex]\n<p><strong>\u041f\u0440\u043e\u0435\u043a\u0446\u0438\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043d\u0430 \u0432\u0435\u043a\u0442\u043e\u0440<\/strong><br \/>\n[latex]{}_{\\vec{b}}\\vec{a} = \\frac{\\vec{a}\\cdot\\vec{b}}{|\\vec{b}|}[\/latex].<\/p>\n<h2>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430<\/h2>\n<pre class=\"lang:java decode:true \">class Main {\r\n\tpublic static void main (String[] args) {\r\n\t\tMyVector a = new MyVector(10.1,-19);\r\n\t\tMyVector b = new MyVector(13,-2.09);\r\n\t\tSystem.out.println(a.vLength());\r\n\t\tSystem.out.println(b.vLength());\r\n\t\tSystem.out.println(MyVector.sum(a,b));\r\n\t\tSystem.out.println(MyVector.sub(a,b));\r\n\t\tSystem.out.println(MyVector.mul(a,8));\r\n\t\tSystem.out.println(MyVector.scalar(a,b));\r\n\t\tSystem.out.println(MyVector.cos(a,b));\r\n\t\tSystem.out.println(MyVector.projection(a,b));\r\n\t\tSystem.out.println(MyVector.isCollinear(a,b));\r\n\t\tSystem.out.println(MyVector.vecProduct(a,b));\r\n\t}\r\n}<\/pre>\n<h2>\u0425\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/h2>\n<p>\u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043a\u043b\u0430\u0441\u0441\u0430: \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445, \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445, \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<h2>\u0412\u044b\u0432\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h2>\n<pre class=\"lang:java decode:true \">21.518\r\n13.167\r\n23.1 ; -21.09\r\n-2.9000000000000004 ; -16.91\r\n80.8 ; -152.0\r\n171.01\r\n0.604\r\n12.98778\r\nfalse\r\n225.80758\r\n<\/pre>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 <a href=\"http:\/\/ideone.com\/X4hscH\" target=\"_blank\">Ideone<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430. \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u043c\u0438 \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u0412\u0435\u043a\u0442\u043e\u0440 &#8212; \u044d\u0442\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u0440\u0435\u0437\u043e\u043a, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0442\u0440\u0435\u0437\u043e\u043a, \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u0434\u043b\u0438\u043d\u0443 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u0413\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u043f\u0440\u044f\u043c\u043e\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b. \u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b: \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430: class MyVector { private double x; private double y; public MyVector(double x, &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=1188\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":81,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[165,166],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/1188"}],"collection":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1188"}],"version-history":[{"count":19,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/1188\/revisions"}],"predecessor-version":[{"id":1238,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/1188\/revisions\/1238"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}