///////////////////////////////////////////// // Variables cercleBase = 1; // S : cercle de base latTympan = 44.01805; // L : Lattitude de la projection stéréographique du tympan // 44.01805 : Montauban // 48.85667 : Paris // 43.91056 : Saint Michel l'Observatoire decliEcliptique = 23.44 ; // D : Déclinaison de l'écliptique resAz=10; // Resolution en degre des cercle d'azimut. ie un cercle tous les resAz degres ///////////////////////////////////////////// // COMMON FUNCTIONS FOR PRJ ASTROLABE ///////////////////////////////////////////// //Projection d'un point M (latitude lat) function proj_M (lat) { proj = 2*cercleBase*tan((90-lat)/2); return proj; } //Converttion degrée vers radian function radians(degrees) { var pi = Math.PI; return degrees * (pi/180); } // Diamètre des almucantarats function diamAlmucantarat(z) { // z: distance zenitale de l'almucantarat b= 2*cercleBase*tan((90-latTympan+z)/2); // point le plus eloigne du pole c= 2*cercleBase*tan((90-latTympan-z)/2); // point le plus près du pole u=b-c; // u: diametre de l'almucantarat return u; } // Offset vertical du centre de l'almucantarat function distAlmucantarat(z) { // z: distance zenitale de l'almucantarat b= 2*cercleBase*tan((90-latTympan+z)/2); // point le plus eloigne du pole c= 2*cercleBase*tan((90-latTympan-z)/2); // point le plus près du pole u=b-c; // u: diametre de l'almucantarat p=b-(u/2); // p: distance du pole au centre de l'almucantarat return p; } // Ajoute du texte à la position XY function AddTextXY(X,Y,Str) { var pos = new RVector(X,Y) // create an operation for adding objects: var op = new RAddObjectsOperation(); // create a text entity and add it to the operation: var text = new RTextEntity( this.getDocument(), new RTextData( pos, // position pos, // alignment point 0.1, // height 2.0, // text width (ignored for now) RS.VAlignBottom, // alignments RS.HAlignCenter, RS.LeftToRight, RS.Exact, 1.0, // line spacing factor Str, // the text "Arial", // font false, // bold false, // italic 0.0, // angle false // simple text without formatting ) ); op.addObject(text); // apply the operation to the current drawing: this.getDocumentInterface().applyOperation(op); } //Ajout de texte en mode polaire (+Offset XY) function AddTextPolar(X,Y,Ro,Teta,Str) { var pos = new RVector(X+Ro*Math.cos(Teta),Y+Ro*Math.sin(Teta)); // create an operation for adding objects: var op = new RAddObjectsOperation(); // create a text entity and add it to the operation: var text = new RTextEntity( this.getDocument(), new RTextData( pos, // position pos, // alignment point 0.05, // height 0.1, // text width (ignored for now) RS.VAlignTop, // alignments RS.HAlignCenter, RS.LeftToRight, RS.Exact, 1.0, // line spacing factor Str, // the text "Arial", // font false, // bold false, // italic Teta, // angle false // simple text without formatting ) ); op.addObject(text); // apply the operation to the current drawing: this.getDocumentInterface().applyOperation(op); } function anglesArcAlmucantarat(R0, R1, Y1) { var N=(Math.pow(R0,2)-Math.pow(R1,2)+Math.pow(Y1,2))/(2*Y1); return Math.asin((Y1-N)/R1); } function anglesArc(R0, Y0, R1, X1, Y1) { var N=(Math.pow(R1,2)-Math.pow(R0,2)-Math.pow(X1,2)-Math.pow(Y1,2)+Math.pow(Y0,2))/(2*(Y0-Y1)); var A=Math.pow(X1/(Y0-Y1),2)+1; var B=-2*Y0*X1/(Y0-Y1)+2*N*X1/(Y0-Y1); var C=Math.pow(Y0,2)+Math.pow(N,2)-Math.pow(R0,2)-2*Y0*N; var D=Math.sqrt(Math.pow(B,2)-4*A*C); //var X=(-B+D)/(2*A); //var Y=N+X*X1/(Y0-Y1); return [(-B+D)/(2*A),(-B-D)/(2*A)]; //return X; } // anglesArc(2.883, 2.077, 3.624, 2.329, -1.925) // anglesArcAlmucantarat(3.047026341389337,2.883778178285558,2.0775409939531815) ///////////////////////////////////////////// // Variables calculées diamEcliptique = 2*cercleBase*(tan((90+decliEcliptique)/2)+tan((90-decliEcliptique)/2)); // E : diamètre de l'écliptique distEcliptique = (diamEcliptique/2)-(2*cercleBase*tan((90-decliEcliptique)/2)); // F : Distance du pole au centre du cercle de l'écliptique distZenit=proj_M(latTympan); ///////////////////////////////////////////// //RObject var pos = new RVector(0,0); var colR = new RColor(255,0,0); var colV = new RColor(0,255,0); var colB = new RColor(0,0,255); var di = this.getDocumentInterface(); var document = this.getDocument(); var op = new RAddObjectsOperation(); ///////////////////////////////////////////// // autre variable var X=0; var Y=0; projTropCan=proj_M(23.44); projTropCapr=proj_M(-23.44); projEqu=proj_M(0); var circTropCapr = new RCircle(new RVector(X,Y), projTropCapr); var circTropCan = new RCircle(new RVector(X,Y), projTropCan); var circEqu = new RCircle(new RVector(X,Y), projEqu); var circTropCaprEntity = new RCircleEntity(document, new RCircleData(circTropCapr)); var circTropCanEntity = new RCircleEntity(document, new RCircleData(circTropCan)); var circEquEntity = new RCircleEntity(document, new RCircleData(circEqu)); op.addObject(circTropCaprEntity, false); op.addObject(circTropCanEntity, false); op.addObject(circEquEntity, false); circTropCaprEntity.setColor(colR); circTropCanEntity.setColor(colR); circEquEntity.setColor(colR); circTropCaprEntity.setLineweight(0); circTropCanEntity.setLineweight(0); circEquEntity.setLineweight(0); ///////////////////////////////////////////// // dessine les Almucantarats var colV = new RColor(0,255,0); for (var i=5; i<=90;i=i+5) { r = diamAlmucantarat(i)/2; dist = distAlmucantarat(i); AddTextXY(0,dist-r,String(i)); if ((r+dist) <= projTropCapr) { var circ = new RCircle(new RVector(0,dist), r); var circEntity = new RCircleEntity(document, new RCircleData(circ)); op.addObject(circEntity, false); circEntity.setColor(colV); circEntity.setLineweight(0); } else { angle = anglesArcAlmucantarat(projTropCapr, r, dist); var arc = new RArc(new RVector(0,dist), r, -angle, Math.PI+angle, true); var arcEntity = new RArcEntity (document, new RArcData(arc)); op.addObject(arcEntity, false); arcEntity.setColor(colV); arcEntity.setLineweight(0); } } ///////////////////////////////////////////// // dessine les courbes d'égal azimut posCentreAzY=(distZenit-2*cercleBase/cos(latTympan)); rAlmu90=diamAlmucantarat(90)/2; distAlmu90=distAlmucantarat(90); for (var az=0; az<=90;az=az+5) { posCentreAzX=2*cercleBase/(cos(latTympan)*tan(az)); rayonAz=2*cercleBase/(cos(latTympan)*sin(az)); X1=anglesArc(projTropCapr,0,rayonAz,posCentreAzX,posCentreAzY); X2=anglesArc(rAlmu90,distAlmu90,rayonAz,posCentreAzX,posCentreAzY); angle1=Math.acos((posCentreAzX-X1[0])/rayonAz); angle2=Math.acos((posCentreAzX-X2[1])/rayonAz); angle3=Math.acos((posCentreAzX-X2[0])/rayonAz); if(X1>X2) { var arc1 = new RArc(new RVector(posCentreAzX,posCentreAzY),rayonAz,Math.PI-angle2,Math.PI-angle3,true); var arc2 = new RArc(new RVector(-posCentreAzX,posCentreAzY),rayonAz,angle2,angle3,false); var arcEntity1 = new RArcEntity (document, new RArcData(arc1)); var arcEntity2 = new RArcEntity (document, new RArcData(arc2)); arcEntity1.setLineweight(0); arcEntity2.setLineweight(0); arcEntity.setColor(colB); op.addObject(arcEntity1, false); op.addObject(arcEntity2, false); AddTextPolar(posCentreAzX,posCentreAzY,rayonAz,Math.PI-angle3,String(az)); AddTextPolar(-posCentreAzX,posCentreAzY,rayonAz,angle3,String(360-az)); AddTextPolar(posCentreAzX,posCentreAzY,rayonAz,Math.PI-angle2,String(180+az)); AddTextPolar(-posCentreAzX,posCentreAzY,rayonAz,angle2,String(180-az)); } else { var arc1 = new RArc(new RVector(posCentreAzX,posCentreAzY),rayonAz,Math.PI-angle2,Math.PI-angle1,true); var arc2 = new RArc(new RVector(-posCentreAzX,posCentreAzY),rayonAz,angle2,angle1,false); var arcEntity1 = new RArcEntity (document, new RArcData(arc1)); var arcEntity2 = new RArcEntity (document, new RArcData(arc2)); arcEntity1.setLineweight(0); arcEntity2.setLineweight(0); //arcEntity.setColor(colB); op.addObject(arcEntity1, false); op.addObject(arcEntity2, false); AddTextPolar(posCentreAzX,posCentreAzY,rayonAz,Math.PI-angle1,String(az)); AddTextPolar(-posCentreAzX,posCentreAzY,rayonAz,angle1,String(360-az)); AddTextPolar(posCentreAzX,posCentreAzY,rayonAz,Math.PI-angle2,String(180+az)); AddTextPolar(-posCentreAzX,posCentreAzY,rayonAz,angle2,String(180-az)); } } // addCircle(posCentreAzX,posCentreAzY,rayonAz); // addCircle(-posCentreAzX,posCentreAzY,rayonAz); ///////////////////////////////////////////// // dessine horizon E/W et meridien N/S //addLine(-projTropCapr,0,projTropCapr,0); //addLine(0,-projTropCapr,0,projTropCapr); var lineNS = new RLine(0,-projTropCapr,0,projTropCapr); var lineEW = new RLine(-projTropCapr,0,projTropCapr,0); var lineNSEntity = new RLineEntity (document, new RLineData(lineNS)); var lineEWEntity = new RLineEntity (document, new RLineData(lineEW)); lineNSEntity.setLineweight(0); lineEWEntity.setLineweight(0); lineNSEntity.setColor(colR); lineEWEntity.setColor(colR); op.addObject(lineNSEntity, false); op.addObject(lineEWEntity, false); //var circ = new RCircle(new RVector(0,dist), r); //var circEntity = new RCircleEntity(document, new RCircleData(circ)); //op.addObject(circEntity, false); //circEntity.setColor(colV); //circEntity.setLineweight(0); //addCircle(0,dist,r); di.applyOperation(op); autoZoom();