- #Using Map function to convert F to C
- def map(value, fromLow, fromHigh, toLow, toHigh):
- fromRange = fromHigh - fromLow
- toRange = toHigh - toLow
- scaleFactor = toRange / fromRange
- tmpValue = value - fromLow
- tmpValue *= scaleFactor
- return tmpValue + toLow
- for tempF in range(-100,220,2):
- tempC=map(tempF,32,212,0,100)
- print(F"F={tempF} tempC={tempC}")
- def cartesianToSpherical(x, y, z):
- theta = math.degrees(math.atan2(math.sqrt((x*x)+(y*y)),z))
- phi = math.degrees(math.atan2(x,y))
- if (theta < 0):
- theta = 360 + theta
- if (phi < 0):
- phi = 360 + phi
- radius = math.sqrt((x * x) + (y * y) + (z * z))
- return theta, phi, radius
- def sphericalToCartesian(centerX, centerY, centerZ, radius, theta, phi):
- thetaRadians = (theta) * math.pi / 180.0
- phiRadians = (phi) * math.pi / 180.0
- x = centerY + (radius * math.sin(phiRadians) * math.sin(thetaRadians))
- y = centerX + (radius * math.cos(phiRadians) * math.sin(thetaRadians))
- z = centerZ + (radius * math.cos(thetaRadians))
- return x,y,z
Map Function c22 s2c
Posted by Anonymous on Sat 30th Jan 2021 01:09
raw | new post
modification of post by Anonymous (view diff)
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.