/*
NewSimpleMotor creates a new motor joint.
*/
346016
func NewSimpleMotor(a, b *Body, rate vect.Float) *SimpleMotor {
    return &SimpleMotor{BasicConstraint: NewConstraint(a, b), rate: rate, jAcc: 0.0}
}
1184919
func newSymbol(size int, quietZoneSize int) *symbol {
	var m symbol

	m.module = make([][]bool, size+2*quietZoneSize)
	m.isUsed = make([][]bool, size+2*quietZoneSize)

	for i := range m.module {
		m.module[i] = make([]bool, size+2*quietZoneSize)
		m.isUsed[i] = make([]bool, size+2*quietZoneSize)
	}

	m.size = size + 2*quietZoneSize
	m.symbolSize = size
	m.quietZoneSize = quietZoneSize

	return &m
}
179394
func newStdoutPrinter(forMachines bool) tablePrinter {
	if forMachines {
		return newMachineReadable(os.Stdout)
	}
	return newHumanReadable(os.Stdout)
}
1122403
func NewSimpleConnector(target string, options map[string]string) Connector {
	return &simpleConnector{backendAddr: target, opts: options}
}
935110
func (g *Driver) OffsetMotorEncoder(motor Motor, offset float64) error {
	offsetUint := math.Float64bits(offset * MOTOR_TICKS_PER_DEGREE)
	return g.writeBytes([]byte{
		goPiGo3Address,
		OFFSET_MOTOR_ENCODER,
		byte(motor),
		byte((offsetUint >> 24) & 0xFF),
		byte((offsetUint >> 16) & 0xFF),
		byte((offsetUint >> 8) & 0xFF),
		byte(offsetUint & 0xFF),
	})
}
276902
func NewButtonDriver(a ble.BLEConnector) *ButtonDriver {
	n := &ButtonDriver{
		name:       gobot.DefaultName("Microbit Button"),
		connection: a,
		Eventer:    gobot.NewEventer(),
	}

	n.AddEvent(ButtonA)
	n.AddEvent(ButtonB)

	return n
}
137975
func NewSimpleLogger3(out io.Writer, prefix string, flag int, l core.LogLevel) *SimpleLogger {
	return &SimpleLogger{
		DEBUG: log.New(out, fmt.Sprintf("%s [debug] ", prefix), flag),
		ERR:   log.New(out, fmt.Sprintf("%s [error] ", prefix), flag),
		INFO:  log.New(out, fmt.Sprintf("%s [info]  ", prefix), flag),
		WARN:  log.New(out, fmt.Sprintf("%s [warn]  ", prefix), flag),
		level: l,
	}
}
830156
func NewStateDriver(name string, instInfo *core.InstanceInfo) (core.StateDriver, error) {
	if name == "" || instInfo == nil {
		return nil, core.Errorf("invalid driver name or configuration passed.")
	}

	if gStateDriver != nil {
		return nil, core.Errorf("statedriver instance already exists.")
	}

	driver, err := initHelper(stateDriverRegistry, name)
	if err != nil {
		return nil, err
	}

	d := driver.(core.StateDriver)
	err = d.Init(instInfo)
	if err != nil {
		return nil, err
	}

	gStateDriver = d
	return d, nil
}
983825
func NewDriver(a ble.BLEConnector) *Driver {
	n := &Driver{
		name:          gobot.DefaultName("Ollie"),
		connection:    a,
		Eventer:       gobot.NewEventer(),
		packetChannel: make(chan *packet, 1024),
	}

	n.AddEvent(Collision)

	return n
}
1331234
func NewMinUnitsWorker(st *state.State) worker.Worker {
	mu := &MinUnitsWorker{st: st}
	return legacy.NewStringsWorker(mu)
}
1247450
func NewIntegrationDriver(name string) (types.IntegrationDriver, error) {

	var ok bool
	var ctor types.NewIntegrationDriver

	func() {
		intDriverCtorsRWL.RLock()
		defer intDriverCtorsRWL.RUnlock()
		ctor, ok = intDriverCtors[strings.ToLower(name)]
	}()

	if !ok {
		return nil, goof.WithField("driver", name, "invalid driver name")
	}

	return NewIntegrationDriverManager(ctor()), nil
}
999332
func (joint *SimpleMotor) ApplyImpulse() {
	a := joint.BodyA
	b := joint.BodyB
	
	// compute relative rotational velocity
	wr := b.w - a.w + joint.rate
	
	jMax := joint.MaxForce
	
	// compute normal impulse
	j := -wr*joint.iSum
	jOld := joint.jAcc
	joint.jAcc = clamp(jOld + j, -jMax, jMax)
	j = joint.jAcc - jOld
	
	// apply impulse
	a.w -= j*a.i_inv
	b.w += j*b.i_inv
}
607318
func NewSimpleLogger(w io.Writer, lvl Level, prefix string, color bool) *Logger {
	l := &Logger{}
	r := NewReceiver(w, prefix)
	r.Color = color
	r.Level = lvl
	l.Receivers = []*Receiver{r}
	l.Active = true
	return l
}
22945
func NewEwmhIcon(X *xgbutil.XUtil, icon *ewmh.WmIcon) *Image {
	ximg := New(X, image.Rect(0, 0, int(icon.Width), int(icon.Height)))
	r := ximg.Rect
	width := r.Dx()

	var argb, x, y int
	for x = r.Min.X; x < r.Max.X; x++ {
		for y = r.Min.Y; y < r.Max.Y; y++ {
			argb = int(icon.Data[x+(y*width)])
			ximg.SetBGRA(x, y, BGRA{
				B: uint8(argb & 0x000000ff),
				G: uint8((argb & 0x0000ff00) >> 8),
				R: uint8((argb & 0x00ff0000) >> 16),
				A: uint8(argb >> 24),
			})
		}
	}
	return ximg
}
452094
func NewDefaultIDGenerator() *IDGenerator {
	globalmachineID.RLock()
	defer globalmachineID.RUnlock()
	if globalmachineID.set {
		return NewIDGenerator(WithMachineID(globalmachineID.id))
	}
	return NewIDGenerator()
}
1333448
func NewButtonDriver(a DigitalReader, pin string, v ...time.Duration) *ButtonDriver {
	b := &ButtonDriver{
		name:         gobot.DefaultName("Button"),
		connection:   a,
		pin:          pin,
		Active:       false,
		DefaultState: 0,
		Eventer:      gobot.NewEventer(),
		interval:     10 * time.Millisecond,
		halt:         make(chan bool),
	}

	if len(v) > 0 {
		b.interval = v[0]
	}

	b.AddEvent(ButtonPush)
	b.AddEvent(ButtonRelease)
	b.AddEvent(Error)

	return b
}
1023993
func NewSPIDriver(spiDevMinor int, sbf spiBusFactory, i func() error) SPIDriver {
	return &spiDriver{
		spiDevMinor: spiDevMinor,
		sbf:         sbf,
		initializer: i,
	}
}