// Acceleration returns the acceleration of the provided x, y, z
490151
func (h *MMA7660Driver) Acceleration(x, y, z float64) (ax, ay, az float64) {
	return x / 21.0, y / 21.0, z / 21.0
}
185174
func (g *Geometry) Interpolate(dist float64) (*Geometry, error) {
	return geomFromC("Interpolate", cGEOSInterpolate(g.g, C.double(dist)))
}
234778
func (w *Window) Move(x, y int) {
	w.Configure(xproto.ConfigWindowX|xproto.ConfigWindowY, x, y, 0, 0, 0, 0)
}
690024
func (*Namespace) Eq(x, y interface{}) bool {
	if e, ok := x.(compare.Eqer); ok {
		return e.Eq(y)
	}

	if e, ok := y.(compare.Eqer); ok {
		return e.Eq(x)
	}

	normalize := func(v interface{}) interface{} {
		if types.IsNil(v) {
			return nil
		}
		vv := reflect.ValueOf(v)
		switch vv.Kind() {
		case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
			return vv.Int()
		case reflect.Float32, reflect.Float64:
			return vv.Float()
		case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
			return vv.Uint()
		default:
			return v
		}
	}
	x = normalize(x)
	y = normalize(y)
	return reflect.DeepEqual(x, y)
}
1259755
func (m *Maze) Move(x, y int, dir Dir) (nx, ny int, ok bool) {
	nx, ny, ok = m.move(x, y, dir)
	ok = ok && m.grid[y][x]&(1<<dir) == 0
	return
}
1325729
func Exponential(factor time.Duration, base float64) Algorithm {
	return func(attempt uint) time.Duration {
		return (factor * time.Duration(math.Pow(base, float64(attempt))))
	}
}
740759
func (bldr *fooBarQueryBuilder) Offset(offset int) *fooBarQueryBuilder {
	bldr.q = bldr.q.Offset(offset)
	if bldr.plugin != nil {
		bldr.plugin.Offset(offset)
	}
	return bldr
}
1043061
func (vm *Machine) arc(x, y, z, i, j, k, rotations float64) {
	var (
		sp                             Position = vm.curPos()
		s1, s2, s3, e1, e2, e3, c1, c2 float64
		add                            func(x, y, z float64)
		clockwise                      bool = (vm.State.MoveMode == MoveModeCWArc)
	)

	if math.IsNaN(x) || math.IsNaN(y) || math.IsNaN(z) ||
		math.IsNaN(i) || math.IsNaN(j) || math.IsNaN(k) {
		panic("Internal failure: Arc attempted with NaN value")
	}

	if rotations < 1 {
		panic("Arc rotations < 1")
	}

	// Ensure that we work on linear moves
	oldState := vm.State.MoveMode
	vm.State.MoveMode = MoveModeLinear
	defer func() {
		vm.State.MoveMode = oldState
	}()

	//  Flip coordinate system for working in other planes
	switch vm.MovePlane {
	case PlaneXY:
		s1, s2, s3, e1, e2, e3, c1, c2 = sp.X, sp.Y, sp.Z, x, y, z, i, j
		add = func(x, y, z float64) {
			vm.move(x, y, z)
		}
	case PlaneXZ:
		s1, s2, s3, e1, e2, e3, c1, c2 = sp.Z, sp.X, sp.Y, z, x, y, k, i
		add = func(x, y, z float64) {
			vm.move(y, z, x)
		}
	case PlaneYZ:
		s1, s2, s3, e1, e2, e3, c1, c2 = sp.Y, sp.Z, sp.X, y, z, x, j, k
		add = func(x, y, z float64) {
			vm.move(z, x, y)
		}
	}

	// Perform arc verification
	radius1 := math.Sqrt(math.Pow(c1-s1, 2) + math.Pow(c2-s2, 2))
	radius2 := math.Sqrt(math.Pow(c1-e1, 2) + math.Pow(c2-e2, 2))
	if radius1 == 0 || radius2 == 0 {
		panic("Invalid arc statement")
	}

	deviation := math.Abs((radius2-radius1)/radius1) * 100
	rDiff := math.Abs(radius2 - radius1)

	if (rDiff > 0.005 && deviation > 0.1) || rDiff > 0.5 {
		panic(fmt.Sprintf("Radius deviation of %f percent and %f mm", deviation, rDiff))
	}

	// Some preparatory math
	theta1 := math.Atan2((s2 - c2), (s1 - c1))
	theta2 := math.Atan2((e2 - c2), (e1 - c1))

	angleDiff := theta2 - theta1
	if angleDiff < 0 && !clockwise {
		angleDiff += 2 * math.Pi
	} else if angleDiff > 0 && clockwise {
		angleDiff -= 2 * math.Pi
	}

	// Rotations are provided as "up to circle count", but we need it as "additional circle count"
	rotations--
	if clockwise {
		angleDiff -= rotations * 2 * math.Pi
	} else {
		angleDiff += rotations * 2 * math.Pi
	}

	steps := 1

	// Enforce a maximum arc deviation
	if vm.MaxArcDeviation < radius1 {
		steps = int(math.Ceil(math.Abs(angleDiff / (2 * math.Acos(1-vm.MaxArcDeviation/radius1)))))
	}

	// Enforce a minimum line length
	arcLen := math.Abs(angleDiff) * math.Sqrt(math.Pow(radius1, 2)+math.Pow((e3-s3)/angleDiff, 2))
	steps2 := int(arcLen / vm.MinArcLineLength)

	if steps > steps2 {
		steps = steps2
	}

	angle := 0.0

	// Execute arc approximation
	if steps > 0 {
		for i := 0; i <= steps; i++ {
			angle = theta1 + angleDiff/float64(steps)*float64(i)
			a1, a2 := c1+radius1*math.Cos(angle), c2+radius1*math.Sin(angle)
			a3 := s3 + (e3-s3)/float64(steps)*float64(i)
			add(a1, a2, a3)
		}
	}

	add(e1, e2, e3)
}
825587
func (x Vector) Abs() Vector {
	y := x.Copy()

	for i, _ := range y {
		y[i] = math.Abs(y[i])
	}

	return y
}
1329663
func (w *Window) JoystickAxis(js Joystick, axis int) float64 {
	return w.currJoy.getAxis(js, axis)
}
562150
func Angle(p0, p1 geom.Coord) float64 {
	dx := p1[0] - p0[0]
	dy := p1[1] - p0[1]
	return math.Atan2(dy, dx)
}
2159
func (s *sample) Drive() {
	degree++
	if degree >= 360 {
		degree = 0
	}

	p := s.ball.GetPosition()
	switch s.buttonState {
	case ctrlUp:
		s.ball.SetPositionY(p.Y + 1)
	case ctrlDown:
		s.ball.SetPositionY(p.Y - 1)
	}

	s.ball.SetRotate(degree * math.Pi / 180)
}
1021887
func (z *ConstNumber) Add(x, y *ConstNumber) *ConstNumber {
	z.Type = promoteConstNumbers(x.Type, y.Type)
	z.Value.Add(&x.Value, &y.Value)
	return z
}
94026
func (m *Matrix) Multiply(m2 *Matrix) (m3 *Matrix, err error) {
	if m.stride*m2.stride != len(m2.elements) {
		return nil, ErrDimensionMismatch
	}

	m3 = &Matrix{epsilon: m.epsilon, stride: m2.stride, elements: make([]float64, (len(m.elements)/m.stride)*m2.stride)}
	for m1c0, m3x := 0, 0; m1c0 < len(m.elements); m1c0 += m.stride {
		for m2r0 := 0; m2r0 < m2.stride; m2r0++ {
			for m1x, m2x := m1c0, m2r0; m2x < len(m2.elements); m2x += m2.stride {
				m3.elements[m3x] += m.elements[m1x] * m2.elements[m2x]
				m1x++
			}
			m3x++
		}
	}
	return
}
444787
func (u Vec) Angle() float64 {
	return math.Atan2(u.Y, u.X)
}
694368
func (v PreciseVector) Vector() Vector {
	// The accuracy flag is ignored on these conversions back to float64.
	x, _ := v.X.Float64()
	y, _ := v.Y.Float64()
	z, _ := v.Z.Float64()
	return Vector{x, y, z}.Normalize()
}
547749
func Flatten(path *Path, flattener Flattener, scale float64) {
	// First Point
	var startX, startY float64
	// Current Point
	var x, y float64
	var i int
	for _, cmp := range path.Components {
		switch cmp {
		case MoveToComponent:
			x, y = path.Points[i], path.Points[i+1]
			startX, startY = x, y
			if i != 0 {
				flattener.End()
			}
			flattener.MoveTo(x, y)
			i += 2
		case LineToComponent:
			x, y = path.Points[i], path.Points[i+1]
			flattener.LineTo(x, y)
			flattener.LineJoin()
			i += 2
		case QuadCurveToComponent:
			// we include the previous point for the start of the curve
			TraceQuad(flattener, path.Points[i-2:], 0.5)
			x, y = path.Points[i+2], path.Points[i+3]
			flattener.LineTo(x, y)
			i += 4
		case CubicCurveToComponent:
			TraceCubic(flattener, path.Points[i-2:], 0.5)
			x, y = path.Points[i+4], path.Points[i+5]
			flattener.LineTo(x, y)
			i += 6
		case ArcToComponent:
			x, y = TraceArc(flattener, path.Points[i], path.Points[i+1], path.Points[i+2], path.Points[i+3], path.Points[i+4], path.Points[i+5], scale)
			flattener.LineTo(x, y)
			i += 6
		case CloseComponent:
			flattener.LineTo(startX, startY)
			flattener.Close()
		}
	}
	flattener.End()
}