def newElement(self): theta = Math.toRadians(self.angle) element = Element(self, complex(R0 * math.cos(theta), R0 * math.sin(theta))) self.angle = self.angle + self.forcedDivergence if self.angle > 360.0: self.angle = self.angle - 360.0 return element
def floatingBuffer(self, vs, into, buffer): map = java.util.HashMap() if len(buffer) == 0: return map d = 360.0 / len(buffer) for i in range(len(buffer)): if self.structLink.isLinked(buffer[i]): path = java.util.ArrayList(1) path.add(buffer[i]) cs = self.singleCS(vs, into, buffer[i], Math.toRadians(i * d)) cs = vs.coords.translate(cs, 0, 0, 100) vs.matcher.add(cs, "Floating_" + buffer[i]) map.put(buffer[i], self.floatingView.geometry.buildMindNet(vs, cs, path)) else: map.put( buffer[i], self.singleCS(vs, into, buffer[i], Math.toRadians(i * d))) return map
def Perpendicular_line(imp, line_info): ## Calculates the parameters for a line that is ## perpendicular to an ROI line. This is the line ## that acts as the depth reference. angle, xbase, ybase, width, height, xend, yend, slope = line_info width, height, nChannels, nSlices, nFrames = imp.getDimensions() b = ybase - (slope*xbase) perp_angle = math.toRadians(angle - 90) slope_new_line = math.tan(perp_angle) return(slope_new_line, b)
def getParticleDeg(pid, mom, theta,phi): theta_rad = Math.toRadians(theta) phi_rad = Math.toRadians(phi) return getParticle(pid,mom,theta_rad,phi_rad)
# 2) The PlotXY axis system assumes that coordinates are a linear # transformation of pixel coordinates. So coordinates on the plotted axes # are not fully correct in some projections. They are correct only for small # angles near the projection reference. # Extract the WCS of the map and put some WCS info into variables wcs = map.wcs crpix1 = wcs.crpix1 crpix2 = wcs.crpix2 crval1 = wcs.crval1 crval2 = wcs.crval2 cdelt1 = wcs.cdelt1 cdelt2 = wcs.cdelt2 naxis1 = wcs.naxis1 naxis2 = wcs.naxis2 # cos(Dec) cosd = Math.cos(Math.toRadians(crval2)) # Set the origin and the scale of the axes so that they coincide with the WCS. myPlot[0].xcdelt = cdelt1 / cosd # note the cos(Dec)!!! myPlot[0].ycdelt = cdelt2 myPlot[0].xcrpix = crpix1 myPlot[0].ycrpix = crpix2 myPlot[0].xcrval = crval1 myPlot[0].ycrval = crval2 # Change the axis type so that we have ticks in degrees/hours, min, sec # and the RA growing toward the left. myPlot.xaxis.type = Axis.RIGHT_ASCENSION myPlot.yaxis.type = Axis.DECLINATION myPlot.xaxis.titleText = "Right Ascension (J2000)" myPlot.yaxis.titleText = "Declination (J2000)" # Set the axes ranges so that the image fills completely the plotting area xrange=[crval1-(crpix1-0.5)*cdelt1/cosd*0.1,\
# 2) The PlotXY axis system assumes that coordinates are a linear # transformation of pixel coordinates. So coordinates on the plotted axes # are not fully correct in some projections. They are correct only for small # angles near the projection reference. # Extract the WCS of the map and put some WCS info into variables wcs=map.wcs crpix1=wcs.crpix1 crpix2=wcs.crpix2 crval1=wcs.crval1 crval2=wcs.crval2 cdelt1=wcs.cdelt1 cdelt2=wcs.cdelt2 naxis1=wcs.naxis1 naxis2=wcs.naxis2 # cos(Dec) cosd=Math.cos(Math.toRadians(crval2)) # Set the origin and the scale of the axes so that they coincide with the WCS. myPlot[0].xcdelt=cdelt1/cosd # note the cos(Dec)!!! myPlot[0].ycdelt=cdelt2 myPlot[0].xcrpix=crpix1 myPlot[0].ycrpix=crpix2 myPlot[0].xcrval=crval1 myPlot[0].ycrval=crval2 # Change the axis type so that we have ticks in degrees/hours, min, sec # and the RA growing toward the left. myPlot.xaxis.type=Axis.RIGHT_ASCENSION myPlot.yaxis.type=Axis.DECLINATION myPlot.xaxis.titleText="Right Ascension (J2000)" myPlot.yaxis.titleText="Declination (J2000)" # Set the axes ranges so that the image fills completely the plotting area xrange=[crval1-(crpix1-0.5)*cdelt1/cosd*0.1,\