{"id":258,"date":"2013-04-05T21:49:52","date_gmt":"2013-04-05T20:49:52","guid":{"rendered":"http:\/\/eboreal.com\/devblog\/?p=258"},"modified":"2022-11-18T07:56:39","modified_gmt":"2022-11-18T06:56:39","slug":"un-vent-nouveau","status":"publish","type":"post","link":"https:\/\/eboreal.com\/devblog\/un-vent-nouveau\/","title":{"rendered":"Un vent nouveau"},"content":{"rendered":"<p>[et_pb_section admin_label=\u00a0\u00bbsection\u00a0\u00bb]<br \/>\n\t\t\t[et_pb_row admin_label=\u00a0\u00bbrow\u00a0\u00bb]<br \/>\n\t\t\t\t[et_pb_column type=\u00a0\u00bb4_4&Prime;][et_pb_text admin_label=\u00a0\u00bbText\u00a0\u00bb]Comme la version pr\u00e9c\u00e9dente ne me convenait pas, j&rsquo;ai d\u00e9cid\u00e9 de reprendre la fa\u00e7on de calculer le vent. Je voulais quelque chose de plus pr\u00e9dictible, de plus simple \u00e0 mettre en \u0153uvre et que l&rsquo;on puisse interroger pour n&rsquo;importe quel point de la carte.<\/p>\n<p>voila le r\u00e9sultat :<\/p>\n<p><a href=\"https:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/Capture-d\u2019e\u0301cran-2013-03-10-a\u0300-23.23.15-copie.png\" data-rel=\"lightbox-gallery-IDhPEjna\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-260\" alt=\"Capture d\u2019e\u0301cran 2013-03-10 a\u0300 23.23.15 - copie\" src=\"https:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/Capture-d\u2019e\u0301cran-2013-03-10-a\u0300-23.23.15-copie.png\" width=\"426\" height=\"321\" srcset=\"https:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/Capture-d\u2019e\u0301cran-2013-03-10-a\u0300-23.23.15-copie.png 426w, https:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/Capture-d\u2019e\u0301cran-2013-03-10-a\u0300-23.23.15-copie-300x226.png 300w\" sizes=\"(max-width: 426px) 100vw, 426px\" \/><\/a><\/p>\n<p>Actuellement les effets sont un peu exag\u00e9r\u00e9s, mais c&rsquo;est pour pouvoir visualiser facilement les effets des c\u00f4tes sur la direction et la force du vent.<\/p>\n<p>L&rsquo;algorithme est assez simple, il consiste \u00e0 chercher dans un certain rayon (actuellement 300 unit\u00e9s) autour du point concern\u00e9 si il y a de la terre. Pour \u00e7a on \u00ab\u00a0lance\u00a0\u00bb des rayons et pour chaque rayon on calcule la somme des altitudes trouv\u00e9es.<\/p>\n<p><a href=\"https:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/IMG_0001.jpg\" data-rel=\"lightbox-gallery-IDhPEjna\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-261\" alt=\"IMG_0001\" src=\"https:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/IMG_0001.jpg\" width=\"532\" height=\"235\" srcset=\"https:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/IMG_0001.jpg 887w, https:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/IMG_0001-300x133.jpg 300w, https:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/IMG_0001-768x339.jpg 768w\" sizes=\"(max-width: 532px) 100vw, 532px\" \/><\/a><\/p>\n<p>La somme des altitudes trouv\u00e9es (pond\u00e9r\u00e9e par la distance au point que l&rsquo;on \u00e9tudie) permet de calculer un effet en force et direction sur le vent g\u00e9n\u00e9ral (vent synoptique). Pour les rayons proches du sens du vent g\u00e9n\u00e9ral, la d\u00e9viation est faible, mais la force du vent est diminu\u00e9e. Par contre pour les rayons aux alentours de 45\u00b0 du vent, la d\u00e9viation sera plus importante. Pour les rayons proches de la perpendiculaire du vent la force sera augment\u00e9e.<\/p>\n<p>&nbsp;<\/p>\n<pre lang=\"java\" line=\"1\">\r\npublic Vector3f getWindComposant(Vector3f location) {\r\n    Vector3f currWind = mainWindDir.mult(data.globalWindSpeed);\r\n    for (int angleDeg = -180; angleDeg &lt; 0; angleDeg += stepAngleDeg) {\r\n        float direction = data.globalWindDirection + (FastMath.DEG_TO_RAD * angleDeg);\r\n        Vector3f dirToExplore = new Quaternion().fromAngleAxis(direction, Vector3f.UNIT_Y).mult(Vector3f.UNIT_Z);\r\n        float heightCoeff = 0;\r\n            for (int displacement = -maxDisplacement; displacement &lt;= maxDisplacement; displacement += stepDisplacement) {\r\n            if (displacement == 0) {\r\n                continue;\r\n            }\r\n            Vector3f posToExplore = location.add(dirToExplore.mult(displacement));\r\n            float height = inGameState.getTerrainHeight(posToExplore);\r\n            heightCoeff += FastMath.abs((float) stepDisplacement \/ (float) displacement) * height;\r\n        }\r\n        heightCoeff = (heightCoeff * data.globalWindSpeed) \/ coeffSum;\r\n        float deviationAngle = data.globalWindDirection + (FastMath.DEG_TO_RAD * ((2 * angleDeg) + 180f));\r\n        Vector3f deviation = new Quaternion().fromAngleAxis(deviationAngle, Vector3f.UNIT_Y).mult(Vector3f.UNIT_Z).mult(heightCoeff);\r\n        currWind.addLocal(deviation);\r\n    }\r\n    float currWindspeed2 = currWind.lengthSquared();\r\n    if (currWindspeed2 &gt; (maxWindSpeed * maxWindSpeed)) {\r\n        currWind.normalizeLocal().multLocal(maxWindSpeed);\r\n    } else if (currWindspeed2 &lt; 1) {\r\n        currWind.normalizeLocal();\r\n    }\r\n    return currWind;\r\n}\r\n<\/pre>\n<p>[\/et_pb_text][\/et_pb_column]<br \/>\n\t\t\t[\/et_pb_row]<br \/>\n\t\t[\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Comme la version pr\u00e9c\u00e9dente ne me convenait pas, j&rsquo;ai d\u00e9cid\u00e9 de reprendre la fa\u00e7on de calculer le vent. Je voulais quelque chose de plus pr\u00e9dictible, de plus simple \u00e0 mettre en \u0153uvre et que l&rsquo;on puisse interroger pour n&rsquo;importe quel point de la carte. voila le r\u00e9sultat : Actuellement les effets sont un peu exag\u00e9r\u00e9s, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":325,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"Comme la version pr\u00e9c\u00e9dente ne me convenait pas, j'ai d\u00e9cid\u00e9 de reprendre la fa\u00e7on de calculer le vent. Je voulais quelque chose de plus pr\u00e9dictible, de plus simple \u00e0 mettre en \u0153uvre et que l'on puisse interroger pour n'importe quel point de la carte.\r\n\r\nvoila le r\u00e9sultat :\r\n\r\n<a href=\"http:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/Capture-d\u2019e\u0301cran-2013-03-10-a\u0300-23.23.15-copie.png\"><img class=\"alignnone size-full wp-image-260\" alt=\"Capture d\u2019e\u0301cran 2013-03-10 a\u0300 23.23.15 - copie\" src=\"http:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/Capture-d\u2019e\u0301cran-2013-03-10-a\u0300-23.23.15-copie.png\" width=\"426\" height=\"321\" \/><\/a>\r\n\r\nActuellement les effets sont un peu exag\u00e9r\u00e9s, mais c'est pour pouvoir visualiser facilement les effets des c\u00f4tes sur la direction et la force du vent.\r\n\r\nL'algorithme est assez simple, il consiste \u00e0 chercher dans un certain rayon (actuellement 300 unit\u00e9s) autour du point concern\u00e9 si il y a de la terre. Pour \u00e7a on \"lance\" des rayons et pour chaque rayon on calcule la somme des altitudes trouv\u00e9es.\r\n\r\n<a href=\"http:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/IMG_0001.jpg\"><img class=\"alignnone  wp-image-261\" alt=\"IMG_0001\" src=\"http:\/\/eboreal.com\/devblog\/wp-content\/uploads\/2013\/04\/IMG_0001.jpg\" width=\"532\" height=\"235\" \/><\/a>\r\n\r\nLa somme des altitudes trouv\u00e9es (pond\u00e9r\u00e9e par la distance au point que l'on \u00e9tudie) permet de calculer un effet en force et direction sur le vent g\u00e9n\u00e9ral (vent synoptique). Pour les rayons proches du sens du vent g\u00e9n\u00e9ral, la d\u00e9viation est faible, mais la force du vent est diminu\u00e9e. Par contre pour les rayons aux alentours de 45\u00b0 du vent, la d\u00e9viation sera plus importante. Pour les rayons proches de la perpendiculaire du vent la force sera augment\u00e9e.\r\n\r\n&nbsp;\r\n<pre lang=\"java\" line=\"1\">\r\npublic Vector3f getWindComposant(Vector3f location) {\r\n    Vector3f currWind = mainWindDir.mult(data.globalWindSpeed);\r\n    for (int angleDeg = -180; angleDeg &lt; 0; angleDeg += stepAngleDeg) {\r\n        float direction = data.globalWindDirection + (FastMath.DEG_TO_RAD * angleDeg);\r\n        Vector3f dirToExplore = new Quaternion().fromAngleAxis(direction, Vector3f.UNIT_Y).mult(Vector3f.UNIT_Z);\r\n        float heightCoeff = 0;\r\n            for (int displacement = -maxDisplacement; displacement &lt;= maxDisplacement; displacement += stepDisplacement) {\r\n            if (displacement == 0) {\r\n                continue;\r\n            }\r\n            Vector3f posToExplore = location.add(dirToExplore.mult(displacement));\r\n            float height = inGameState.getTerrainHeight(posToExplore);\r\n            heightCoeff += FastMath.abs((float) stepDisplacement \/ (float) displacement) * height;\r\n        }\r\n        heightCoeff = (heightCoeff * data.globalWindSpeed) \/ coeffSum;\r\n        float deviationAngle = data.globalWindDirection + (FastMath.DEG_TO_RAD * ((2 * angleDeg) + 180f));\r\n        Vector3f deviation = new Quaternion().fromAngleAxis(deviationAngle, Vector3f.UNIT_Y).mult(Vector3f.UNIT_Z).mult(heightCoeff);\r\n        currWind.addLocal(deviation);\r\n    }\r\n    float currWindspeed2 = currWind.lengthSquared();\r\n    if (currWindspeed2 &gt; (maxWindSpeed * maxWindSpeed)) {\r\n        currWind.normalizeLocal().multLocal(maxWindSpeed);\r\n    } else if (currWindspeed2 &lt; 1) {\r\n        currWind.normalizeLocal();\r\n    }\r\n    return currWind;\r\n}\r\n<\/pre>","_et_gb_content_width":"","footnotes":""},"categories":[3,4,13],"tags":[14],"class_list":["post-258","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-a-la-une","category-blog","category-sail-boat-sim-race","tag-code","et-has-post-format-content","et_post_format-et-post-format-standard"],"_links":{"self":[{"href":"https:\/\/eboreal.com\/devblog\/wp-json\/wp\/v2\/posts\/258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eboreal.com\/devblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eboreal.com\/devblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eboreal.com\/devblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eboreal.com\/devblog\/wp-json\/wp\/v2\/comments?post=258"}],"version-history":[{"count":10,"href":"https:\/\/eboreal.com\/devblog\/wp-json\/wp\/v2\/posts\/258\/revisions"}],"predecessor-version":[{"id":3532,"href":"https:\/\/eboreal.com\/devblog\/wp-json\/wp\/v2\/posts\/258\/revisions\/3532"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/eboreal.com\/devblog\/wp-json\/wp\/v2\/media\/325"}],"wp:attachment":[{"href":"https:\/\/eboreal.com\/devblog\/wp-json\/wp\/v2\/media?parent=258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eboreal.com\/devblog\/wp-json\/wp\/v2\/categories?post=258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eboreal.com\/devblog\/wp-json\/wp\/v2\/tags?post=258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}