当前位置: 首页>>代码示例>>Golang>>正文


Golang math.Atan函数代码示例

本文整理汇总了Golang中math.Atan函数的典型用法代码示例。如果您正苦于以下问题:Golang Atan函数的具体用法?Golang Atan怎么用?Golang Atan使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Atan函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: BackAzimuth

func (p Place) BackAzimuth(point Place) float64 {

	if (p.Latitude == point.Latitude) && (p.Longitude == point.Longitude) {
		return 0.0
	}

	esq := (1.0 - 1.0/298.25) * (1.0 - 1.0/298.25)
	alat3 := math.Atan(math.Tan(p.Latitude/RadiansToDegrees)*esq) * RadiansToDegrees
	alat4 := math.Atan(math.Tan(point.Latitude/RadiansToDegrees)*esq) * RadiansToDegrees

	rlat1 := alat3 / RadiansToDegrees
	rlat2 := alat4 / RadiansToDegrees
	rdlon := (point.Longitude - p.Longitude) / RadiansToDegrees

	clat1 := math.Cos(rlat1)
	clat2 := math.Cos(rlat2)
	slat1 := math.Sin(rlat1)
	slat2 := math.Sin(rlat2)
	cdlon := math.Cos(rdlon)
	sdlon := math.Sin(rdlon)

	ybaz := -sdlon * clat1
	xbaz := clat2*slat1 - slat2*clat1*cdlon

	baz := RadiansToDegrees * math.Atan2(ybaz, xbaz)

	if baz < 0.0 {
		baz += 360.0
	}

	return baz
}
开发者ID:GeoNet,项目名称:delta,代码行数:32,代码来源:place.go

示例2: Initialize

func (view *ViewData) Initialize() {
	twoPi := 8.0 * math.Atan(1.0)
	halfCone := float64(view.FieldOfView) * float64(twoPi/360.0) / 2.0
	adjustedHalfCone := math.Asin(float64(view.ScreenWidth) * math.Sin(halfCone) / float64(view.StandardScreenWidth))
	var worldToScreen float64

	view.HalfScreenWidth = view.ScreenWidth / 2
	view.HalfScreenHeight = view.ScreenHeight / 2

	// if there's a round-off error in half_cone, we want to make the cone too big (so when we clip lines to the edge of the screen they're actually off the screen, thus +1.0)
	view.HalfCone = Angle(adjustedHalfCone*(float64(NumberOfAngles))/twoPi + 1.0)

	// calculate world_to_screen; we could calculate this with standard_screen_width/2 and the old half_cone and get the same result
	worldToScreen = float64(view.HalfScreenWidth) / math.Tan(adjustedHalfCone)
	tmp0 := int16((worldToScreen / float64(view.HorizontalScale)) + 0.5)
	tmp1 := int16((worldToScreen / float64(view.VerticalScale)) + 0.5)
	view.WorldToScreen.X = tmp0
	view.RealWorldToScreen.X = tmp0
	view.WorldToScreen.Y = tmp1
	view.RealWorldToScreen.Y = tmp1

	// cacluate the vertical cone angle; again, overflow instead of underflow when rounding
	view.HalfVerticalCone = Angle(NumberOfAngles*math.Atan((float64(view.HalfScreenHeight*view.VerticalScale)/worldToScreen))/twoPi + 1.0)

	// calculate left edge vector
	view.UntransformedLeftEdge.I = WorldDistance(view.WorldToScreen.X)
	view.UntransformedLeftEdge.J = WorldDistance(-view.HalfScreenWidth)

	// calculate right edge vector (negative, so it clips in the right direction)
	view.UntransformedRightEdge.I = WorldDistance(-view.WorldToScreen.X)
	view.UntransformedRightEdge.J = WorldDistance(-view.HalfScreenWidth)

	// reset any effects
	view.Effect = cseries.None
}
开发者ID:DrItanium,项目名称:moo,代码行数:35,代码来源:render.go

示例3: Distance

func (p Place) Distance(point Place) float64 {

	if (p.Latitude == point.Latitude) && (p.Longitude == point.Longitude) {
		return 0.0
	}

	esq := (1.0 - 1.0/298.25) * (1.0 - 1.0/298.25)
	alat3 := math.Atan(math.Tan(p.Latitude/RadiansToDegrees)*esq) * RadiansToDegrees
	alat4 := math.Atan(math.Tan(point.Latitude/RadiansToDegrees)*esq) * RadiansToDegrees

	rlat1 := alat3 / RadiansToDegrees
	rlat2 := alat4 / RadiansToDegrees
	rdlon := (point.Longitude - p.Longitude) / RadiansToDegrees

	clat1 := math.Cos(rlat1)
	clat2 := math.Cos(rlat2)
	slat1 := math.Sin(rlat1)
	slat2 := math.Sin(rlat2)
	cdlon := math.Cos(rdlon)

	cdel := slat1*slat2 + clat1*clat2*cdlon
	switch {
	case cdel > 1.0:
		cdel = 1.0
	case cdel < -1.0:
		cdel = -1.0
	}

	return RadiansToKm * math.Acos(cdel)
}
开发者ID:GeoNet,项目名称:delta,代码行数:30,代码来源:place.go

示例4: Azimuth

func (p Place) Azimuth(point Place) float64 {

	if (p.Latitude == point.Latitude) && (p.Longitude == point.Longitude) {
		return 0.0
	}

	esq := (1.0 - 1.0/298.25) * (1.0 - 1.0/298.25)
	alat3 := math.Atan(math.Tan(p.Latitude/RadiansToDegrees)*esq) * RadiansToDegrees
	alat4 := math.Atan(math.Tan(point.Latitude/RadiansToDegrees)*esq) * RadiansToDegrees

	rlat1 := alat3 / RadiansToDegrees
	rlat2 := alat4 / RadiansToDegrees
	rdlon := (point.Longitude - p.Longitude) / RadiansToDegrees

	clat1 := math.Cos(rlat1)
	clat2 := math.Cos(rlat2)
	slat1 := math.Sin(rlat1)
	slat2 := math.Sin(rlat2)
	cdlon := math.Cos(rdlon)
	sdlon := math.Sin(rdlon)

	yazi := sdlon * clat2
	xazi := clat1*slat2 - slat1*clat2*cdlon

	azi := RadiansToDegrees * math.Atan2(yazi, xazi)

	if azi < 0.0 {
		azi += 360.0
	}

	return azi
}
开发者ID:GeoNet,项目名称:delta,代码行数:32,代码来源:place.go

示例5: AnomalyDistance

// AnomalyDistance returns true anomaly and distance for near-parabolic orbits.
//
// Distance r returned in AU.
// An error is returned if the algorithm fails to converge.
func (e *Elements) AnomalyDistance(jde float64) (ν unit.Angle, r float64, err error) {
	// fairly literal translation of code on p. 246
	q1 := base.K * math.Sqrt((1+e.Ecc)/e.PDis) / (2 * e.PDis) // line 20
	g := (1 - e.Ecc) / (1 + e.Ecc)                            // line 20

	t := jde - e.TimeP // line 22
	if t == 0 {        // line 24
		return 0, e.PDis, nil
	}
	d1, d := 10000., 1e-9        // line 14
	q2 := q1 * t                 // line 28
	s := 2. / (3 * math.Abs(q2)) // line 30
	s = 2 / math.Tan(2*math.Atan(math.Cbrt(math.Tan(math.Atan(s)/2))))
	if t < 0 { // line 34
		s = -s
	}
	if e.Ecc != 1 { // line 36
		l := 0 // line 38
		for {
			s0 := s // line 40
			z := 1.
			y := s * s
			g1 := -y * s
			q3 := q2 + 2*g*s*y/3 // line 42
			for {
				z += 1                          // line 44
				g1 = -g1 * g * y                // line 46
				z1 := (z - (z+1)*g) / (2*z + 1) // line 48
				f := z1 * g1                    // line 50
				q3 += f                         // line 52
				if z > 50 || math.Abs(f) > d1 { // line 54
					return 0, 0, errors.New("No convergence")
				}
				if math.Abs(f) <= d { // line 56
					break
				}
			}
			l++ // line 58
			if l > 50 {
				return 0, 0, errors.New("No convergence")
			}
			for {
				s1 := s // line 60
				s = (2*s*s*s/3 + q3) / (s*s + 1)
				if math.Abs(s-s1) <= d { // line 62
					break
				}
			}
			if math.Abs(s-s0) <= d { // line 64
				break
			}
		}
	}
	ν = unit.Angle(2 * math.Atan(s))               // line 66
	r = e.PDis * (1 + e.Ecc) / (1 + e.Ecc*ν.Cos()) // line 68
	if ν < 0 {                                     // line 70
		ν += 2 * math.Pi
	}
	return
}
开发者ID:soniakeys,项目名称:meeus,代码行数:64,代码来源:nearparabolic.go

示例6: cartesianToGeographic

func (pt *Point) cartesianToGeographic(meridien float64, a float64, e float64, eps float64) {

	x := pt.X
	y := pt.Y
	z := pt.Z

	lon := meridien + math.Atan(y/x)

	module := math.Sqrt(x*x + y*y)

	phi_0 := math.Atan(z / (module * (1 - (a*e*e)/math.Sqrt(x*x+y*y+z*z))))

	phi_i := math.Atan(z / module / (1 - a*e*e*math.Cos(phi_0)/(module*math.Sqrt(1-e*e*math.Sin(phi_0)*math.Sin(phi_0)))))

	delta := 100.0
	for delta > eps {

		phi_0 = phi_i
		phi_i = math.Atan(z / module / (1 - a*e*e*math.Cos(phi_0)/(module*math.Sqrt(1-e*e*math.Sin(phi_0)*math.Sin(phi_0)))))
		delta = math.Abs(phi_i - phi_0)
	}
	he := module/math.Cos(phi_i) - a/math.Sqrt(1-e*e*math.Sin(phi_i)*math.Sin(phi_i))

	pt.X = lon
	pt.Y = phi_i
	pt.Z = he
	pt.Unit = Radian
}
开发者ID:jeromenerf,项目名称:lambertgo,代码行数:28,代码来源:transformations.go

示例7: Skew

func (sfc *pdfSurface) Skew(xRadians float64, yRadians float64) {

	x := math.Atan(xRadians)
	y := math.Atan(yRadians)

	sfc.alterMatrix(1, x, y, 1, 0, 0)
}
开发者ID:vincentshi,项目名称:dox2go,代码行数:7,代码来源:pdf_draw.go

示例8: CalculateFunction

func (self *Calc) CalculateFunction(funcName string, arg32 float32) float32 {
	if len(self.errors) > 0 {
		return 1
	}

	var result float64
	arg := float64(arg32)
	switch funcName {
	case "sin":
		result = math.Sin(self.DegToRad(arg))
	case "cos":
		result = math.Cos(self.DegToRad(arg))
	case "tg":
		result = math.Tan(self.DegToRad(arg))
	case "ctg":
		result = 1.0 / math.Tan(self.DegToRad(arg))
	case "arcsin":
		result = self.RadToDeg(math.Asin(arg))
	case "arccos":
		result = self.RadToDeg(math.Acos(arg))
	case "arctg":
		result = self.RadToDeg(math.Atan(arg))
	case "arcctg":
		result = self.RadToDeg(math.Atan(1 / arg))
	case "sqrt":
		result = math.Sqrt(arg)
	default:
		self.errors = append(self.errors, "Unknown identifier "+funcName)
		return 1
	}

	return float32(result)
}
开发者ID:science-saf,项目名称:automata-theory-1,代码行数:33,代码来源:Calc.go

示例9: ProbContestSmall

// ProbContestSmall computes the probability for a contest between u and v where u wins if it's
// the smaller value. φ ∃ [0,1] is a scaling factor that helps v win even if it's not smaller.
// If φ==0, deterministic analysis is carried out. If φ==1, probabilistic analysis is carried out.
// As φ → 1, v "gets more help".
func ProbContestSmall(u, v, φ float64) float64 {
	u = math.Atan(u)/math.Pi + 1.5
	v = math.Atan(v)/math.Pi + 1.5
	if u < v {
		return v / (v + φ*u)
	}
	if u > v {
		return φ * v / (φ*v + u)
	}
	return 0.5
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:15,代码来源:pareto.go

示例10: GetEuler

// Get matrix rotation as Euler angles in degrees
func (m *Mat3) GetEuler() *V3 {
	x := math.Atan((-m.matrix[5]) / m.matrix[8])
	y := math.Asin(m.matrix[2])
	z := math.Atan((-m.matrix[1]) / m.matrix[0])

	// Convert to Degrees
	x *= 180 / math.Pi
	y *= 180 / math.Pi
	z *= 180 / math.Pi

	return NewV3(x, y, z)
}
开发者ID:flameofwar,项目名称:s3dm-go,代码行数:13,代码来源:mat3.go

示例11: GetEuler

// Get M rotation as Euler angles in degrees
func (m *Mat3) GetEuler() *Vec3 {
	x := math.Atan((-m.M[5]) / m.M[8])
	y := math.Asin(m.M[2])
	z := math.Atan((-m.M[1]) / m.M[0])

	// Convert to Degrees
	x *= 180 / math.Pi
	y *= 180 / math.Pi
	z *= 180 / math.Pi

	return V3(x, y, z)
}
开发者ID:swantescholz,项目名称:go,代码行数:13,代码来源:mat3.go

示例12: latitudeFromLatitudeISO

func latitudeFromLatitudeISO(lat_iso float64, e float64, eps float64) float64 {

	phi_0 := 2*math.Atan(math.Exp(lat_iso)) - math.Pi/2
	phi_i := 2*math.Atan(math.Pow((1+e*math.Sin(phi_0))/(1-e*math.Sin(phi_0)), e/2)*math.Exp(lat_iso)) - math.Pi/2

	delta := 100.0
	for delta > eps {
		phi_0 = phi_i
		phi_i = 2*math.Atan(math.Pow((1+e*math.Sin(phi_0))/(1-e*math.Sin(phi_0)), e/2.0)*math.Exp(lat_iso)) - math.Pi/2
		delta = math.Abs(phi_i - phi_0)
	}
	return phi_i
}
开发者ID:jeromenerf,项目名称:lambertgo,代码行数:13,代码来源:transformations.go

示例13: main

func main() {
	fmt.Printf("sin(%9.6f deg) = %f\n", d, math.Sin(d*math.Pi/180))
	fmt.Printf("sin(%9.6f rad) = %f\n", r, math.Sin(r))
	fmt.Printf("cos(%9.6f deg) = %f\n", d, math.Cos(d*math.Pi/180))
	fmt.Printf("cos(%9.6f rad) = %f\n", r, math.Cos(r))
	fmt.Printf("tan(%9.6f deg) = %f\n", d, math.Tan(d*math.Pi/180))
	fmt.Printf("tan(%9.6f rad) = %f\n", r, math.Tan(r))
	fmt.Printf("asin(%f) = %9.6f deg\n", s, math.Asin(s)*180/math.Pi)
	fmt.Printf("asin(%f) = %9.6f rad\n", s, math.Asin(s))
	fmt.Printf("acos(%f) = %9.6f deg\n", c, math.Acos(c)*180/math.Pi)
	fmt.Printf("acos(%f) = %9.6f rad\n", c, math.Acos(c))
	fmt.Printf("atan(%f) = %9.6f deg\n", t, math.Atan(t)*180/math.Pi)
	fmt.Printf("atan(%f) = %9.6f rad\n", t, math.Atan(t))
}
开发者ID:travis1230,项目名称:RosettaCodeData,代码行数:14,代码来源:trigonometric-functions.go

示例14: Update

/**
* Returns the yaw pitch and roll angles, respectively defined as the angles in radians between
* the Earth North and the IMU Z axis (yaw), the Earth ground plane and the IMU Y axis (pitch)
* and the Earth ground plane and the IMU X axis (roll).
*
* Returns Yaw, Pitch and Roll angles in radians
**/
func (imu *ImuMayhony) Update(when int64, gx, gy, gz, ax, ay, az, mx, my, mz float32) (yaw, pitch, roll float32) {
	var (
		gravx, gravy, gravz float64 // estimated gravity direction
	)
	imu.sampleFreq = 1.0 / (float32(when-imu.lastUpdate) / 1000000000.0) // nanoseconds to fractions of a second
	imu.lastUpdate = when
	ahrsUpdate(imu, gx, gy, gz, ax, ay, az, mx, my, mz)
	gravx = float64(2.0 * (imu.q1*imu.q3 - imu.q0*imu.q2))
	gravy = float64(2.0 * (imu.q0*imu.q1 + imu.q2*imu.q3))
	gravz = float64(imu.q0*imu.q0 - imu.q1*imu.q1 - imu.q2*imu.q2 + imu.q3*imu.q3)
	yaw = float32(math.Atan2(float64(2.0*imu.q1*imu.q2-2.0*imu.q0*imu.q3), float64(2.0*imu.q0*imu.q0+2.0*imu.q1*imu.q1-1.0)))
	pitch = float32(math.Atan(gravx / math.Sqrt(gravy*gravy+gravz*gravz)))
	roll = float32(math.Atan(gravy / math.Sqrt(gravx*gravx+gravz*gravz)))
	return
}
开发者ID:prussiap,项目名称:goPiCopter,代码行数:22,代码来源:ImuMayhony.go

示例15: GridToGeodetic

//GridToGeodetic converts RT90 coordinates to WGS84
func GridToGeodetic(x, y float64) (float64, float64) {

	if CentralMeridian == 31337.0 {
		return 0.0, 0.0
	}

	e2 := Flattening * (2.0 - Flattening)
	n := Flattening / (2.0 - Flattening)
	a_roof := Axis / (1.0 + n) * (1.0 + n*n/4.0 + n*n*n*n/64.0)
	delta1 := n/2.0 - 2.0*n*n/3.0 + 37.0*n*n*n/96.0 - n*n*n*n/360.0
	delta2 := n*n/48.0 + n*n*n/15.0 - 437.0*n*n*n*n/1440.0
	delta3 := 17.0*n*n*n/480.0 - 37*n*n*n*n/840.0
	delta4 := 4397.0 * n * n * n * n / 161280.0

	Astar := e2 + e2*e2 + e2*e2*e2 + e2*e2*e2*e2
	Bstar := -(7.0*e2*e2 + 17.0*e2*e2*e2 + 30.0*e2*e2*e2*e2) / 6.0
	Cstar := (224.0*e2*e2*e2 + 889.0*e2*e2*e2*e2) / 120.0
	Dstar := -(4279.0 * e2 * e2 * e2 * e2) / 1260.0

	DegToRad := math.Pi / 180
	LambdaZero := CentralMeridian * DegToRad
	xi := (x - FalseNorthing) / (Scale * a_roof)
	eta := (y - FalseEasting) / (Scale * a_roof)
	xi_prim := xi - delta1*math.Sin(2.0*xi)*math.Cosh(2.0*eta) - delta2*math.Sin(4.0*xi)*math.Cosh(4.0*eta) - delta3*math.Sin(6.0*xi)*math.Cosh(6.0*eta) - delta4*math.Sin(8.0*xi)*math.Cosh(8.0*eta)
	eta_prim := eta - delta1*math.Cos(2.0*xi)*math.Sinh(2.0*eta) - delta2*math.Cos(4.0*xi)*math.Sinh(4.0*eta) - delta3*math.Cos(6.0*xi)*math.Sinh(6.0*eta) - delta4*math.Cos(8.0*xi)*math.Sinh(8.0*eta)
	phi_star := math.Asin(math.Sin(xi_prim) / math.Cosh(eta_prim))
	delta_lambda := math.Atan(math.Sinh(eta_prim) / math.Cos(xi_prim))
	lon_radian := LambdaZero + delta_lambda
	lat_radian := phi_star + math.Sin(phi_star)*math.Cos(phi_star)*(Astar+Bstar*math.Pow(math.Sin(phi_star), 2)+Cstar*math.Pow(math.Sin(phi_star), 4)+Dstar*math.Pow(math.Sin(phi_star), 6))

	return lat_radian * 180.0 / math.Pi, lon_radian * 180.0 / math.Pi
}
开发者ID:peterstark72,项目名称:golang-skanetrafiken,代码行数:33,代码来源:geo.go


注:本文中的math.Atan函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。