Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <craft>
- <info>
- <title>Test connecting two stars</title>
- </info>
- <!-- TEST WITH URSA MAJOR -->
- <craft name="merak" module="Ek-x_"/>
- <craft name="dubhe" module="Vk9aP"/>
- <craft name="phecda" module="V1n9P"/>
- <craft name="megrez" module="Vksuv"/>
- <craft name="alkaid" module="VkLLP"/>
- <craft name="alioth" module="VJMXD"/>
- <craft name="mizar" module="E1L07"/>
- <craft name="connector" module="4kOBg"/>
- <part name="constellation">
- <alkaid flat="1"></alkaid>
- <mizar flat="1"></mizar>
- </part>
- <constellation></constellation>
- <!--<script src="math.js" type="text/javascript">-->
- <script>
- var order="alkaid/mizar/alioth/megrez/phecda/merak/dubhe/megrez"
- var constellation=[]
- var angle = {}
- for(var i=0; i < this.children[0].children.length; i++){
- constellation.push({
- name:this.children[0].children[i].name,
- x:this.children[0].children[i].$scope.parameters.x,
- y:this.children[0].children[i].$scope.parameters.y,
- z:this.children[0].children[i].$scope.parameters.z,
- radius:this.children[0].children[0].children[0].attribs.radius
- });
- /*if (i>0){
- angle = Math.atan2(constellation[i-1].z, constellation[i-1].y) - Math.atan2(constellation[i].z, constellation[i].y)
- angle = angle * 180 / Math.PI
- console.log(angle)
- }*/
- }
- //console.log(this.children[0].children[0].children[0].attribs.radius)
- function calculateDistance(x1,y1,z1,x2,y2,z2){
- var x = Math.abs(x1-x2);
- var y = Math.abs(y1-y2);
- var z = 0//Math.abs(z1-z2);
- console.log("px: "+x1,x2+" py: "+y1,y2+" d: "+(Math.pow(x,2)+Math.pow(y,2)+Math.pow(z,2)))
- return Math.sqrt(Math.pow(x,2)+Math.pow(y,2)+Math.pow(z,2));
- }
- var d = calculateDistance(constellation[1].x,constellation[1].y,constellation[1].z,constellation[0].x,constellation[0].y,constellation[0].z);
- var width = Math.min(constellation[0].radius,constellation[1].radius);
- angle.x = Math.asin((constellation[0].x - constellation[1].x)/d) * 180 / Math.PI
- angle.y = Math.acos((constellation[0].y - constellation[1].y)/d) * 180 / Math.PI
- angle.z = 0//Math.asin((constellation[0].z - constellation[1].z)/d) * 180 / Math.PI
- /*angle.x= 0
- angle.y = 0
- angle.z = 0*/
- console.log("**x: "+angle.x+" y: "+angle.y+" z: "+angle.z)
- /*var a = [constellation[0].x,constellation[0].y,constellation[0].z]
- var b = [constellation[1].x,constellation[1].y,constellation[1].z]
- var dot = math.dot(a,b)
- var cross = math.cross(a,b)
- var norm = math.norm(cross)
- var angle = Math.atan2(norm, dot)*/
- //angle = Math.atan2(Math.norm(),Math.dot(a,b));
- this.add('<connector length="'+d+'" width="'+width+'" t="translate('+constellation[0].x+', '+constellation[0].y+', '+constellation[0].z+') rotateZ(50)"></connector>')
- </script>
- </craft>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement