$(function () { $.ajax({ type: 'GET', url: 'https://ptx.transportdata.tw/MOTC/v2/Rail/TRA/Station?$top=10&$format=JSON', //欲呼叫之API網址(此範例為台鐵車站資料) dataType: 'json', headers: GetAuthorizationHeader(), success: function (Data) { $('body').text(JSON.stringify(Data)); } }); });
/* Simple Hello World in Node.js */ var StringSet = require('stringset'); value = [ '"norm"', '"average"', '"average out"', '"mean"', '"ordinary"', '"middling"', '"mediocre"', '"fair"', '"medium"', '"intermediate"', '"modal"', '"median"' ] var synonym_set =new StringSet(value.trim().split(",").slice(1,-1)); console.log("Hello World");
var CryptoJS = require("crypto-js"); var stringSecretData = 'Lorem ipsum dolor sit amet, ...'.repeat(2); var password = 'RadwagSecretPassPhaserdg09acostam'; var encrypted = CryptoJS.AES.encrypt(stringSecretData, password).toString(); console.log(encrypted); var decrypted = CryptoJS.AES.decrypt(encrypted.toString(), password); console.log(decrypted.toString(CryptoJS.enc.Utf8));
/*Prototype course plotter!*/ Math.radians = function(degrees){ return degrees * Math.PI / 180; }; Math.degrees = function(radians){ return radians / (Math.PI / 180) }; //Global Parameters var time = 0; var dt = 0.5; var trueAnom; var alt; var altAct; var orbVel; var velX; var velY; var g1; var g; var heading; var GM = 6513917.8; //Planet Parameters var rad = 1000; g1 = 1.63; //Ship Parameters var mass = 1000; var thrust = 10000; var maxAccel = thrust / mass*-1; //Expandable Orbit Parameters as arrays //var Ap[]; //var Pe[]; //var ApRa[]; //var PeRa[]; //var ecc1[]; //var SMA1[]; //var SmA[]; //var orbPeriod[]; //var ApVel[]; //var angVel[]; //Orbit Parameters //Orbit 1 var Ap1 = 0; var Pe1 = 0; var ApRa1 = Ap1 + rad; var PeRa1 = Pe1 + rad; var ecc1 = (PeRa1 - ApRa1)/(PeRa1 + ApRa1); var SMA1 = (ApRa1+PeRa1)/2; var SmA1 = SMA1 * (Math.sqrt(1-(ecc1*ecc1))); var orbPeriod1 = 2*Math.PI*Math.sqrt((SMA1*SMA1*SMA1)/GM); var ApVel1 = Math.sqrt(GM*((2/ApRa1)-(1/SMA1))) var angVel1 = 360/orbPeriod1; //Orbit 2 var Ap2 = 200; var Pe2 = 200; var ApRa2 = Ap2 + rad; var PeRa2 = Pe2 + rad; var ecc2 = (PeRa2 - ApRa2)/(PeRa2 + ApRa2); var SMA2 = (ApRa2+PeRa2)/2; var SmA2 = SMA2 * (Math.sqrt(1-(ecc2*ecc2))); var orbPeriod2 = 2*Math.PI*Math.sqrt((SMA2*SMA2*SMA2)/GM); var ApVel2 = Math.sqrt(GM*((2/ApRa2)-(1/SMA2))); //Landing Orbit var Ap3 = 100; var Pe3 = 50; var ApRa3 = Ap3 + rad; var PeRa3 = Pe3 + rad; var ecc3 = (PeRa3 - ApRa3)/(PeRa3 + ApRa3); var SMA3 = (ApRa3+PeRa3)/2; var SmA3 = SMA3 * (Math.sqrt(1-(ecc3*ecc3))); var orbPeriod3 = 2*Math.PI*Math.sqrt((SMA3*SMA3*SMA3)/GM); var ApVel3 = Math.sqrt(GM*((2/ApRa3)-(1/SMA3))); //Orbit Parameters var orbVel; var SMA; var H; var P; var ecc; var SmA; var c; var currentAp; var currentPe; //Start Parameters var startLoc = 0; var xStart = Math.cos(Math.radians(startLoc))*ApRa1; var zStart = Math.sin(Math.radians(startLoc))*ApRa1; var xStartVel = 0;//Math.sin(Math.radians(startLoc))*ApVel1; var zStartVel = 0;//Math.cos(Math.radians(startLoc))*ApVel1; //Launch Parameters var launchState = true; var turnEnd = 50; var turnExp = 0.8; xStartVel = 0; zStartVel = 0; if(Ap1 === 0){ } var launchProfile = 0; //Burn 1 var burn1dV = ApVel2-ApVel1; var burn1Dur = Math.abs(burn1dV/maxAccel); var burn1Start = ((orbPeriod1/2)-(burn1Dur/2)); var burn1End = ((orbPeriod1/2)+(burn1Dur/2)); //Burn 2 var burn2dV = ApVel3-ApVel2; var burn2Dur = Math.abs(burn2dV/maxAccel); var burn2Start = ((orbPeriod1/2)+(orbPeriod2/2)-(burn2Dur/2)); var burn2End = ((orbPeriod1/2)+(orbPeriod2/2)+(burn2Dur/2)); //Calculated Landing Parameters var landingTime; var landingPosX; var landingPosZ; var landingVelX; var landingVelZ; var landingVel; //End Parameters var orbitPosX = []; var orbitPosZ = []; var orbitObj = {orbitPosX, orbitPosZ, dt}; //Orbit Variables var posX; var posZ; var velX; var velZ; var gAccX; var gAccZ; var tAccX=0; var tAccZ=0; var accXSum; var accZSum; var alt; var orbPeriodSum = orbPeriod1 + orbPeriod2; //Initialise posX = xStart; posZ = zStart; velX = xStartVel; velZ = zStartVel*-1; alt = Math.sqrt((posX*posX) + (posZ * posZ)); trueAnom = Math.atan2((posZ),posX); g = (GM*-1)/(alt*alt); accX = g*Math.cos(trueAnom); accZ = g*Math.sin(trueAnom); console.log("+++++++++ INPUT ORBIT PARAMETERS +++++++++++") console.log(""); console.log("START ORBIT (ORBIT 1)"); console.log("Max Accel : " + maxAccel); console.log("Apoapsis : " + Ap1 + "m"); console.log("Periapsis : " + Pe1 + "m"); console.log("Orbital Period : " + orbPeriod1 + "s"); console.log("Eccentricity : " + ecc1); console.log("Angular Velocity : " + angVel1 + "deg/s"); console.log(""); console.log("TRANSFER ORBIT (ORBIT 2)") console.log("Apoapsis : " + Ap2 + "m"); console.log("Periapsis : " + Pe2 + "m"); console.log("Orbital Period : " + orbPeriod2 + "s"); console.log("Eccentricity : " + ecc2); console.log(""); console.log("++++++++ INPUT START PARAMETERS ++++++++++++"); console.log(""); console.log("Start X :" + posX + " Start Z :" + posZ); console.log("Start Vel : " + Math.sqrt((velX*velX)+(velZ*velZ))); console.log("Burn 1 dV : " + burn1dV); console.log("Burn 1 Duration :" + burn1Dur); console.log("Burn 2 dV : " + burn2dV); console.log("Burn 2 Duration :" + burn2Dur); console.log(""); var check = false; var manouverCount = 3; //manouver manager loop for (var i = 0; i<manouverCount; i++){ } //calculation loop for(var i = 0; i<(((orbPeriod1/2)+(orbPeriod2/2)+(orbPeriod3/2))/dt);i++){ //Current State Calculations time = time + dt; alt = Math.sqrt((posX*posX) + (posZ*posZ)); g = (GM*-1)/(alt*alt); trueAnom = Math.atan2((posZ),posX); gAccX = g*Math.cos(trueAnom); gAccZ = g*Math.sin(trueAnom); heading = Math.radians(Math.degrees(trueAnom)+90); //Burn Calculations //Circularisation Burn(s) /* if(time >= burn1Start && time <= burn1End){ tAccX = Math.abs(maxAccel * Math.cos(heading)); tAccZ = Math.abs(maxAccel * Math.sin(heading)); var tTot = Math.sqrt((tAccX*tAccX)+(tAccZ*tAccZ)); //console.log("burn1 " + time) }else if(time >= burn2Start && time <= burn2End){ tAccX = -1*Math.abs(maxAccel * Math.cos(heading)); tAccZ = -1*Math.abs(maxAccel * Math.sin(heading)); var tTot = Math.sqrt((tAccX*tAccX)+(tAccZ*tAccZ)); //console.log("burn2 " + time) }//else if(){} else{tAccX =0;tAccZ =0;} */ //Launch Burn if(launchState === true){ if(currentPe < PeRa2){ console.log("O.o"); launchProfile = Math.pow((alt-rad)/turnEnd, turnExp)+(Math.radians(startLoc)); tAccX = -1*(maxAccel * Math.cos(launchProfile)); tAccZ = -1*(maxAccel * Math.sin(launchProfile)); console.log(alt-rad); console.log("Current Pe : " + currentPe); console.log("Current Ap : " + currentAp); console.log("Current Lean Angle : " + launchProfile); console.log("time : " + time); } } //Acc, Vel, Pos Calculations accXSum = gAccX - tAccX; accZSum = gAccZ - tAccZ; velX = velX + ((accXSum))*dt; velZ = velZ + ((accZSum))*dt; posX = posX + ((velX))*dt; posZ = posZ + ((velZ))*dt; orbitPosX[i] = posX; orbitPosZ[i] = posZ; //Current Orbit Calculations orbVel = Math.sqrt((velX*velX)+(velZ*velZ)); SMA = 1/((2/alt)-((orbVel*orbVel)/GM)); H = (posX*velZ)-(posZ*velX); P=(H*H)/GM; ecc = Math.sqrt(1-P/(SMA)); SmA = SMA*Math.sqrt(1-(ecc*ecc)); c=Math.sqrt((SMA*SMA)-(SmA*SmA)); currentAp = SMA + c; currentPe = SMA -c; /* if(alt<995&&check == false){ check = true; landingTime = time; landingPosX = posX; landingPosZ = posZ; landingVelX = velX; landingVelZ = velZ; landingVel = Math.sqrt((landingVelX*landingVelX)+(landingVelZ*landingVelZ)); } */ } console.log(""); console.log("+++++++++ INTERCEPT FLIGHT PARAMETERS +++++++++++"); console.log(""); console.log("Number of Calculations : " + i); console.log("Total Mission Time : " + time); console.log(""); console.log("FINAL POSITION"); console.log("Time = " + time); console.log("pos X = " + posX + " pos Z = " + posZ); console.log("acc X = " + accXSum + " acc Z = " + accZSum); console.log("vel X = " + velX + " vel Z = " + velZ); console.log("Alt = " + alt); console.log("Stored Position X = " + orbitObj.orbitPosX[i-1]); console.log("Stored Position Z = " + orbitObj.orbitPosZ[i-1]); console.log("Alt from stored = " + Math.sqrt(((orbitObj.orbitPosX[i-1])*(orbitObj.orbitPosX[i-1]))+((orbitObj.orbitPosZ[i-1])*(orbitObj.orbitPosZ[i-1])))); console.log("Intercept Apoapsis = " + currentAp); console.log("Intercept Periapsis = " + currentPe); console.log(""); console.log("++++++++++++++ CALCULATED LANDING PARAMETERS ++++++++++++++++"); console.log(""); console.log("Landing Time : " + landingTime); console.log("Landing Position X : " + landingPosX); console.log("Landing Position Z : " + landingPosZ); console.log("Landing Velocity X : " + landingVelX); console.log("Landing Velocity Z : " + landingVelZ); console.log("Landing Velocity Magnitude : " + landingVel);
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more