Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. <craft>
  2. <info>
  3. <title>Test connecting two stars</title>
  4. </info>
  5.  
  6.  
  7. <!-- TEST WITH URSA MAJOR -->
  8. <craft name="merak" module="Ek-x_"/>
  9. <craft name="dubhe" module="Vk9aP"/>
  10. <craft name="phecda" module="V1n9P"/>
  11. <craft name="megrez" module="Vksuv"/>
  12. <craft name="alkaid" module="VkLLP"/>
  13. <craft name="alioth" module="VJMXD"/>
  14. <craft name="mizar" module="E1L07"/>
  15.  
  16. <craft name="connector" module="4kOBg"/>
  17.  
  18. <part name="constellation">
  19. <alkaid flat="1"></alkaid>
  20. <mizar flat="1"></mizar>
  21. </part>
  22.  
  23. <constellation></constellation>
  24. <!--<script src="math.js" type="text/javascript">-->
  25. <script>
  26. var order="alkaid/mizar/alioth/megrez/phecda/merak/dubhe/megrez"
  27. var constellation=[]
  28. var angle = {}
  29.  
  30. for(var i=0; i < this.children[0].children.length; i++){
  31. constellation.push({
  32. name:this.children[0].children[i].name,
  33. x:this.children[0].children[i].$scope.parameters.x,
  34. y:this.children[0].children[i].$scope.parameters.y,
  35. z:this.children[0].children[i].$scope.parameters.z,
  36. radius:this.children[0].children[0].children[0].attribs.radius
  37. });
  38.  
  39. /*if (i>0){
  40. angle = Math.atan2(constellation[i-1].z, constellation[i-1].y) - Math.atan2(constellation[i].z, constellation[i].y)
  41. angle = angle * 180 / Math.PI
  42. console.log(angle)
  43. }*/
  44.  
  45. }
  46.  
  47. //console.log(this.children[0].children[0].children[0].attribs.radius)
  48.  
  49.  
  50.  
  51. function calculateDistance(x1,y1,z1,x2,y2,z2){
  52. var x = Math.abs(x1-x2);
  53. var y = Math.abs(y1-y2);
  54. var z = 0//Math.abs(z1-z2);
  55. console.log("px: "+x1,x2+" py: "+y1,y2+" d: "+(Math.pow(x,2)+Math.pow(y,2)+Math.pow(z,2)))
  56. return Math.sqrt(Math.pow(x,2)+Math.pow(y,2)+Math.pow(z,2));
  57. }
  58.  
  59.  
  60. var d = calculateDistance(constellation[1].x,constellation[1].y,constellation[1].z,constellation[0].x,constellation[0].y,constellation[0].z);
  61. var width = Math.min(constellation[0].radius,constellation[1].radius);
  62.  
  63. angle.x = Math.asin((constellation[0].x - constellation[1].x)/d) * 180 / Math.PI
  64. angle.y = Math.acos((constellation[0].y - constellation[1].y)/d) * 180 / Math.PI
  65. angle.z = 0//Math.asin((constellation[0].z - constellation[1].z)/d) * 180 / Math.PI
  66.  
  67. /*angle.x= 0
  68. angle.y = 0
  69. angle.z = 0*/
  70. console.log("**x: "+angle.x+" y: "+angle.y+" z: "+angle.z)
  71.  
  72. /*var a = [constellation[0].x,constellation[0].y,constellation[0].z]
  73. var b = [constellation[1].x,constellation[1].y,constellation[1].z]
  74. var dot = math.dot(a,b)
  75. var cross = math.cross(a,b)
  76. var norm = math.norm(cross)
  77. var angle = Math.atan2(norm, dot)*/
  78. //angle = Math.atan2(Math.norm(),Math.dot(a,b));
  79.  
  80.  
  81.  
  82. this.add('<connector length="'+d+'" width="'+width+'" t="translate('+constellation[0].x+', '+constellation[0].y+', '+constellation[0].z+') rotateZ(50)"></connector>')
  83. </script>
  84.  
  85. </craft>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement