// Clockwise causes the drone to spin in clockwise direction
// speed can be a value from `0` to `100`.
438514
func (a *Driver) Clockwise(speed int) {
	a.adaptor().drone.Clockwise(speed)
}
1265606
func (b *AESGCMBarrier) Rotate(ctx context.Context) (uint32, error) {
	b.l.Lock()
	defer b.l.Unlock()
	if b.sealed {
		return 0, ErrBarrierSealed
	}

	// Generate a new key
	encrypt, err := b.GenerateKey()
	if err != nil {
		return 0, errwrap.Wrapf("failed to generate encryption key: {{err}}", err)
	}

	// Get the next term
	term := b.keyring.ActiveTerm()
	newTerm := term + 1

	// Add a new encryption key
	newKeyring, err := b.keyring.AddKey(&Key{
		Term:    newTerm,
		Version: 1,
		Value:   encrypt,
	})
	if err != nil {
		return 0, errwrap.Wrapf("failed to add new encryption key: {{err}}", err)
	}

	// Persist the new keyring
	if err := b.persistKeyring(ctx, newKeyring); err != nil {
		return 0, err
	}

	// Swap the keyrings
	b.keyring = newKeyring
	return newTerm, nil
}
541383
func reversed(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
	var iterable Iterable
	if err := UnpackPositionalArgs("reversed", args, kwargs, 1, &iterable); err != nil {
		return nil, err
	}
	iter := iterable.Iterate()
	defer iter.Done()
	var elems []Value
	if n := Len(args[0]); n >= 0 {
		elems = make([]Value, 0, n) // preallocate if length known
	}
	var x Value
	for iter.Next(&x) {
		elems = append(elems, x)
	}
	n := len(elems)
	for i := 0; i < n>>1; i++ {
		elems[i], elems[n-1-i] = elems[n-1-i], elems[i]
	}
	return NewList(elems), nil
}
1335240
func (s *StepperDriver) step() error {
	if s.direction == "forward" {
		s.stepNum++
	} else {
		s.stepNum--
	}

	if s.stepNum >= int(s.stepsPerRev) {
		s.stepNum = 0
	} else if s.stepNum < 0 {
		s.stepNum = int(s.stepsPerRev) - 1
	}

	r := int(math.Abs(float64(s.stepNum))) % len(s.phase)

	for i, v := range s.phase[r] {
		if err := s.connection.DigitalWrite(s.pins[i], v); err != nil {
			return err
		}
	}

	return nil
}
1048886
func (a *AdafruitMotorHatDriver) SetStepperMotorSpeed(stepperMotor int, rpm int) (err error) {
	revSteps := a.stepperMotors[stepperMotor].revSteps
	a.stepperMotors[stepperMotor].secPerStep = 60.0 / float64(revSteps*rpm)
	a.stepperMotors[stepperMotor].stepCounter = 0
	return
}
1040339
func completeRotation(clock clockwork.Clock, ca services.CertAuthority) error {
	rotation := ca.GetRotation()
	signingKeys := ca.GetSigningKeys()
	checkingKeys := ca.GetCheckingKeys()
	keyPairs := ca.GetTLSKeyPairs()

	signingKeys = signingKeys[:1]
	checkingKeys = checkingKeys[:1]
	keyPairs = keyPairs[:1]

	rotation.Started = time.Time{}
	rotation.State = services.RotationStateStandby
	rotation.Phase = services.RotationPhaseStandby
	rotation.LastRotated = clock.Now()
	rotation.Mode = ""
	rotation.Schedule = services.RotationSchedule{}

	ca.SetSigningKeys(signingKeys)
	ca.SetCheckingKeys(checkingKeys)
	ca.SetTLSKeyPairs(keyPairs)
	ca.SetRotation(rotation)
	return nil
}
1351099
func (m *MotorDriver) Speed(value byte) (err error) {
	if writer, ok := m.connection.(PwmWriter); ok {
		m.CurrentMode = "analog"
		m.CurrentSpeed = value
		return writer.PwmWrite(m.SpeedPin, value)
	}
	return ErrPwmWriteUnsupported
}
1036434
func (r Ring) Orientation() Orientation {
	area := 0.0

	// This is a fast planar area computation, which is okay for this use.
	// implicitly move everything to near the origin to help with roundoff
	offsetX := r[0][0]
	offsetY := r[0][1]
	for i := 1; i < len(r)-1; i++ {
		area += (r[i][0]-offsetX)*(r[i+1][1]-offsetY) -
			(r[i+1][0]-offsetX)*(r[i][1]-offsetY)
	}

	if area > 0 {
		return CCW
	}

	if area < 0 {
		return CW
	}

	// degenerate case, no area
	return 0
}
436605
func (matrix *Matrix) Rotate(radians float64) {
	C.cairo_matrix_rotate((*C.cairo_matrix_t)(unsafe.Pointer(matrix)), C.double(radians))
}
620133
func (vr *vectorRenderer) Circle(radius float64, x, y int) {
	vr.c.Circle(x, y, int(radius), vr.s.GetFillAndStrokeOptions())
}
725959
func (gp *GoPdf) Rotate(angle, x, y float64) {
	gp.UnitsToPointsVar(&x, &y)
	gp.getContent().appendRotate(angle, x, y)
}
846505
func RotateRight16(x uint16, k int) uint16 {
	if k < 0 {
		panic("negative rotation count")
	}
	const n = 16
	s := uint(k) & (n - 1)
	return x<<(n-s) | x>>s
}
549706
func (m *MotorDriver) Speed(speed int16) error {
	m.syncRoot.Lock()
	defer m.syncRoot.Unlock()
	if m.halted {
		return nil
	}
	m.speedHelper(speed)
	return nil
}
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)
}
883095
func (t T) Circle(center kml.Coordinate, radius, maxErr float64) []kml.Coordinate {
	numVertices := int(math.Ceil(math.Pi / math.Acos((radius-maxErr)/(radius+maxErr))))
	cs := make([]kml.Coordinate, numVertices+1)
	for i := 0; i < numVertices; i++ {
		cs[i] = t.Offset(center, radius, 360*float64(i)/float64(numVertices))
	}
	cs[numVertices] = cs[0]
	return cs
}
1130906
func Reverse(u []byte) []byte {
	// Special-case 16 bit UUIDS for speed.
	l := len(u)
	if l == 2 {
		return []byte{u[1], u[0]}
	}
	b := make([]byte, l)
	for i := 0; i < l/2+1; i++ {
		b[i], b[l-i-1] = u[l-i-1], u[i]
	}
	return b
}
382948
func (s *StringCodeGenerator) Spindle(enabled, clockwise bool, speed float64) {
	x := ""
	if s.Position.State.SpindleEnabled != enabled || s.Position.State.SpindleClockwise != clockwise {
		s.ForceModeWrite = true
		if enabled && clockwise {
			x += "M3"
		} else if enabled && !clockwise {
			x += "M4"
		} else {
			x += "M5"
		}
	}

	if enabled && s.Position.State.SpindleSpeed != speed {
		x += fmt.Sprintf("S%s", floatToString(speed, s.Precision))
	}

	s.put(x)
}