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


Golang math.Acos函数代码示例

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


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

示例1: GetAngleRad

// Get the angle in radians of the rotation this quaternion represents. Does not normalize the quaternion. Use
// {@link #getAxisAngleRad(Vector3)} to get both the axis and the angle of this rotation. Use
// {@link #getAngleAroundRad(Vector3)} to get the angle around a specific axis.
// return the angle in radians of the rotation
func (self *Quaternion) GetAngleRad() float32 {
	if self.w > 1 {
		return float32(2.0 * math.Acos(float64(self.w/self.Len())))
	} else {
		return float32(2.0 * math.Acos(float64(self.w)))
	}
}
开发者ID:pyros2097,项目名称:spike,代码行数:11,代码来源:quaternion.go

示例2: Aa

// Aa gets the rotation of quaternion q as an axis and angle.
// The axis (x, y, z) and the angle in radians is returned.
// The return elements will be zero if the length of the quaternion is 0.
// See:
//    http://web.archive.org/web/20041029003853/...
//    ...http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q57
func (q *Q) Aa() (ax, ay, az, angle float64) {
	sinSqr := 1 - q.W*q.W
	if AeqZ(sinSqr) {
		return 1, 0, 0, 2 * math.Acos(q.W)
	}
	sin := 1 / math.Sqrt(sinSqr)
	return q.X * sin, q.Y * sin, q.Z * sin, 2 * math.Acos(q.W)
}
开发者ID:krattai,项目名称:monoflow,代码行数:14,代码来源:quaternion.go

示例3: main

func main() {
	fmt.Println("cos(pi/2):", math.Cos(math.Pi/2))
	fmt.Println("cos(0):", math.Cos(0))
	fmt.Println("sen(pi/2):", math.Sin(math.Pi/2))
	fmt.Println("sen(0):", math.Sin(0))
	fmt.Println("arccos(1):", math.Acos(1))
	fmt.Println("arccos(0):", math.Acos(0))
	fmt.Println("arcsen(1):", math.Asin(1))
	fmt.Println("arcsen(0):", math.Asin(0))
}
开发者ID:7hi4g0,项目名称:Codes,代码行数:10,代码来源:cosSin.go

示例4: CircleCircleIntersectionArea

// CircleCircleIntersectionArea returns the intersection area of 2 circles.
func CircleCircleIntersectionArea(a, b Circle) float64 {
	d := Dist(a.Point, b.Point)
	if Sign(d) <= 0 || d+a.R <= b.R || d+b.R <= a.R {
		return Sqr(math.Min(a.R, b.R)) * math.Pi
	}
	if d >= a.R+b.R {
		return 0
	}

	da := (Sqr(d) + Sqr(a.R) - Sqr(b.R)) / d / 2
	db := d - da
	return Sqr(a.R)*math.Acos(da/a.R) - da*math.Sqrt(Sqr(a.R)-Sqr(da)) + Sqr(b.R)*math.Acos(db/b.R) - db*math.Sqrt(Sqr(b.R)-Sqr(db))
}
开发者ID:kelvinlau,项目名称:go,代码行数:14,代码来源:circle.go

示例5: 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

示例6: Distance

// Distance returns the approximate distance from another point in kilometers.
func (p Point) Distance(p2 Point) float64 {
	r := 6371.01
	return math.Acos((math.Sin(p.RadLat())*
		math.Sin(p2.RadLat()))+
		(math.Cos(p.RadLat())*math.Cos(p2.RadLat())*
			math.Cos(p.RadLon()-p2.RadLon()))) * r
}
开发者ID:dustin,项目名称:go-aprs,代码行数:8,代码来源:server.go

示例7: Slerp

// Spherically interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is
// stored in this vector.
// target The target vector
// alpha The interpolation coefficient.
func (self *Vector3) Slerp(target *Vector3, alpha float32) *Vector3 {
	dot := self.DotV(target)
	// If the inputs are too close for comfort, simply linearly interpolate.
	if dot > 0.9995 || dot < -0.9995 {
		return self.Lerp(target, alpha)
	}

	// theta0 = angle between input vectors
	theta0 := float32(math.Acos(float64(dot)))
	// theta = angle between this vector and result
	theta := theta0 * alpha

	st := float32(math.Sin(float64(theta)))
	tx := target.X - self.X*dot
	ty := target.Y - self.Y*dot
	tz := target.Z - self.Z*dot
	l2 := tx*tx + ty*ty + tz*tz
	var dl float32
	if l2 < 0.0001 {
		dl = st * 1
	} else {
		dl = st * 1 / float32(math.Sqrt(float64(l2)))
	}
	return self.SclScalar(float32(math.Cos(float64(theta)))).Add(tx*dl, ty*dl, tz*dl).Nor()
}
开发者ID:pyros2097,项目名称:spike,代码行数:29,代码来源:vector3.go

示例8: Slerp

// Spherical linear interpolation.
// t is the interpolation value from 0. to 1.
// p and q are 'const'. m is *not*
func (m Quaternion) Slerp(t float64, p, q Quaternion) Quaternion {

	cs := p.Dot(q)
	angle := math.Acos(cs)

	if math.Fabs(angle) >= internalε {
		sn := math.Sin(angle)
		invSn := 1. / sn
		tAngle := t * angle
		coeff0 := math.Sin(angle-tAngle) * invSn
		coeff1 := math.Sin(tAngle) * invSn

		m[0] = float64(coeff0*p[0] + coeff1*q[0])
		m[1] = float64(coeff0*p[1] + coeff1*q[1])
		m[2] = float64(coeff0*p[2] + coeff1*q[2])
		m[3] = float64(coeff0*p[3] + coeff1*q[3])
	} else {
		m[0] = p[0]
		m[1] = p[1]
		m[2] = p[2]
		m[3] = p[3]
	}

	return m
}
开发者ID:eadf,项目名称:math3d,代码行数:28,代码来源:quaternion.go

示例9: CreateSphere

func CreateSphere(o2w, w2o *Transform, ro bool, rad, z0, z1, pm float64) *Sphere {
	s := new(Sphere)
	s.objectToWorld = o2w
	s.worldToObject = w2o
	s.reverseOrientation = ro
	s.transformSwapsHandedness = SwapsHandednessTransform(s.objectToWorld)
	s.shapeId = GenerateShapeId()
	s.radius = rad
	s.Zmin = Clamp(math.Min(z0, z1), -s.radius, s.radius)
	s.Zmax = Clamp(math.Max(z0, z1), -s.radius, s.radius)
	s.thetaMin = math.Acos(Clamp(s.Zmin/s.radius, -1.0, 1.0))
	s.thetaMax = math.Acos(Clamp(s.Zmax/s.radius, -1.0, 1.0))
	s.phiMax = Radians(Clamp(pm, 0.0, 360.0))

	return s
}
开发者ID:rweyrauch,项目名称:gopbrt,代码行数:16,代码来源:sphere.go

示例10: AstrometricJ2000

// AstrometricJ2000 is a utility function for computing astrometric coordinates.
//
// It is used internally and only exported so that it can be used from
// multiple packages.  It is not otherwise expected to be used.
//
// Argument f is a function that returns J2000 equatorial rectangular
// coodinates of a body.
//
// Results are J2000 right ascention, declination, and elongation.
func AstrometricJ2000(f func(float64) (x, y, z float64), jde float64, e *pp.V87Planet) (α, δ, ψ float64) {
	X, Y, Z := solarxyz.PositionJ2000(e, jde)
	x, y, z := f(jde)
	// (33.10) p. 229
	ξ := X + x
	η := Y + y
	ζ := Z + z
	Δ := math.Sqrt(ξ*ξ + η*η + ζ*ζ)
	{
		τ := base.LightTime(Δ)
		x, y, z = f(jde - τ)
		ξ = X + x
		η = Y + y
		ζ = Z + z
		Δ = math.Sqrt(ξ*ξ + η*η + ζ*ζ)
	}
	α = math.Atan2(η, ξ)
	if α < 0 {
		α += 2 * math.Pi
	}
	δ = math.Asin(ζ / Δ)
	R0 := math.Sqrt(X*X + Y*Y + Z*Z)
	ψ = math.Acos((ξ*X + η*Y + ζ*Z) / R0 / Δ)
	return
}
开发者ID:thecc4re,项目名称:meeus,代码行数:34,代码来源:elliptic.go

示例11: TestTofloat

func TestTofloat(t *testing.T) {
	oldval := cfg.UseRadians
	cfg.UseRadians = true
	type test struct {
		in  string
		out float64
	}
	var tests []test = []test{
		{"2.5+2.5", 2.5 + 2.5},
		{"2.5*2.5", 2.5 * 2.5},
		{"3/2", 3. / 2.},
		{"2^10", math.Pow(2, 10)},
		{"sqrt(2)", math.Sqrt(2)},
		{"sin(2)", math.Sin(2)},
		{"cos(2)", math.Cos(2)},
		{"tan(2)", math.Tan(2)},
		{"arcsin(0.3)", math.Asin(0.3)},
		{"arccos(0.3)", math.Acos(0.3)},
		{"arctan(0.3)", math.Atan(0.3)},
		{"ln(2)", math.Log(2)},
		{"log(2)", math.Log10(2)},
	}
	for _, k := range tests {
		result := TextToCas(k.in).Tofloat()
		if result != k.out {
			t.Errorf("Tofloat: In:%v Out:%v Result:%v",
				k.in, k.out, result)
		}
	}
	cfg.UseRadians = oldval
}
开发者ID:Englebabz,项目名称:CasGO,代码行数:31,代码来源:Sharedmethods_test.go

示例12: arc

func arc(t VertexConverter, x, y, rx, ry, start, angle, scale float64) (lastX, lastY float64) {
	end := start + angle
	clockWise := true
	if angle < 0 {
		clockWise = false
	}
	ra := (math.Abs(rx) + math.Abs(ry)) / 2
	da := math.Acos(ra/(ra+0.125/scale)) * 2
	//normalize
	if !clockWise {
		da = -da
	}
	angle = start + da
	var curX, curY float64
	for {
		if (angle < end-da/4) != clockWise {
			curX = x + math.Cos(end)*rx
			curY = y + math.Sin(end)*ry
			return curX, curY
		}
		curX = x + math.Cos(angle)*rx
		curY = y + math.Sin(angle)*ry

		angle += da
		t.Vertex(curX, curY)
	}
	return curX, curY
}
开发者ID:nolenroyalty,项目名称:bangarang,代码行数:28,代码来源:arc.go

示例13: SphericalDistance

/*
	SphericalDistance calculates the distance (in meters) between two WGS84 points
*/
func SphericalDistance(lat1, lon1, lat2, lon2 float64) int {

	// Convert latitude and longitude to
	// spherical coordinates in radians.
	degrees_to_radians := math.Pi / 180.0

	// phi = 90 - latitude
	phi1 := (90.0 - lat1) * degrees_to_radians
	phi2 := (90.0 - lat2) * degrees_to_radians

	// theta = longitude
	theta1 := lon1 * degrees_to_radians
	theta2 := lon2 * degrees_to_radians

	/*
	   Compute spherical distance from spherical coordinates.

	   For two locations in spherical coordinates
	   	(1, theta, phi) and (1, theta, phi)
	   	cosine( arc length ) =
	   		sin phi sin phi' cos(theta-theta') + cos phi cos phi'
	   	distance = rho * arc length
	*/
	cos := (math.Sin(phi1)*math.Sin(phi2)*math.Cos(theta1-theta2) +
		math.Cos(phi1)*math.Cos(phi2))
	arc := math.Acos(cos)

	// Remember to multiply arc by the radius of the earth
	//in your favorite set of units to get length.
	return int(6373 * 1000 * arc)
}
开发者ID:peterstark72,项目名称:golang-skanetrafiken,代码行数:34,代码来源:geo.go

示例14: main

func main() {
	// Triangle Rectangle
	Tr := [3][2]float64{{0, 0}, {50, 0}, {50, 30}}

	// Sides
	a := Tr[2][0] - Tr[0][0]
	b := Tr[2][0] - Tr[0][0]
	c := M.Sqrt(M.Pow(a, 2) + M.Pow(b, 2))

	// Reason of b over c, or
	// How many times c is b?
	bc := b / c
	ac := a / c

	// Angle in vertex Tr[0]
	ß := M.Asin(bc)

	println("Sin after Asin: ", M.Sin(ß), bc, M.Sin(ß) == bc)
	println("Cos after Asin: ", M.Cos(ß), ac, M.Cos(ß) == bc, M.Cos(ß)-bc)

	// Angle in vertex Tr[0]
	ß = M.Acos(ac)
	println("Sin after Acos: ", M.Sin(ß), bc, M.Sin(ß) == bc, M.Sin(ß)-bc)
	println("Cos after Acos: ", M.Cos(ß), ac, M.Cos(ß) == bc)
}
开发者ID:OpenVE,项目名称:ComputerScience,代码行数:25,代码来源:test_sin_cos.go

示例15: xacos

func xacos() {
	r := popr()
	if r< -1-paminstr.Eps || r>1+paminstr.Eps {
		panic("acos argument out of [-1.0, 1.0]")
	}
	pushr(math.Acos(r))
}
开发者ID:Christopheraburns,项目名称:clive,代码行数:7,代码来源:builtin.go


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