// TraceArc trace an arc using a Liner
502837
func TraceArc(t Liner, 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.LineTo(curX, curY)
	}
}
1347941
func (b *executorBuilder) buildTrace(v *plannercore.Trace) Executor {
	return &TraceExec{
		baseExecutor: newBaseExecutor(b.ctx, v.Schema(), v.ExplainID()),
		stmtNode:     v.StmtNode,
		builder:      b,
		format:       v.Format,
	}
}
570247
func Trace(yes bool) func(r *Rego) {
	return func(r *Rego) {
		r.trace = yes
	}
}
20370
func (g *Group) Trace(path string, handler context.Handler) {
	g.Handle(http.MethodTrace, path, handler)
}
199313
func TraceQuad(t Liner, quad []float64, flatteningThreshold float64) {
	const curveLen = CurveRecursionLimit * 6
	const curveEndIndex = curveLen - 1
	const lastIteration = CurveRecursionLimit - 1

	// Allocates curves stack
	curves := make([]float64, curveLen)

	// copy 6 elements from the quad path to the stack
	copy(curves[0:6], quad[0:6])

	var i int
	var c []float64
	var dx, dy, d float64

	for i >= 0 {
		c = traceGetWindow(curves, i)
		dx, dy, d = traceCalcDeltas(c)

		// bail early if the distance is 0
		if d == 0 {
			return
		}

		// if it's flat then trace a line
		if traceIsFlat(dx, dy, d, flatteningThreshold) || i == lastIteration {
			t.LineTo(c[4], c[5])
			i--
		} else {
			SubdivideQuad(c, traceGetWindow(curves, i+1), traceGetWindow(curves, i))
			i++
		}
	}
}
561720
func (r Req) TraceLog(span opentracing.Span) {
	span.LogFields(
		log.Object("key", r.MKey),
		log.String("target", r.Target),
		log.String("pattern", r.Pattern),
		log.Int("from", int(r.From)),
		log.Int("to", int(r.To)),
		log.Int("span", int(r.To-r.From-1)),
		log.Int("mdp", int(r.MaxPoints)),
		log.Int("rawInterval", int(r.RawInterval)),
		log.String("cons", r.Consolidator.String()),
		log.String("consReq", r.ConsReq.String()),
		log.Int("schemaId", int(r.SchemaId)),
		log.Int("aggId", int(r.AggId)),
		log.Int("archive", r.Archive),
		log.Int("archInterval", int(r.ArchInterval)),
		log.Int("TTL", int(r.TTL)),
		log.Int("outInterval", int(r.OutInterval)),
		log.Int("aggNum", int(r.AggNum)),
	)
}
354909
func (l *Logger) Tracef(format string, v ...interface{}) {
	if l.trace {
		l.logger.Printf(l.traceLabel+format, v...)
	}
}
1017712
func (me *Logger) Tracef(format string, v ...interface{}) {
	me.printf(Ptrace, format, v...)
}
1069067
func (l *Logger) Tracef(format string, v ...interface{}) {
	if l.getLevel() <= Trace {
		l.getHandler().Log(l.name, Trace, fmt.Sprintf(format, v...), 1)
	}
}
1249076
func Tracef(format string, v ...interface{}) {
	defaultLogs.TRACE().Output(2, fmt.Sprintf(format, v...))
}
338117
func (r Route) Trace() string {
	printfmt := fmt.Sprintf("%s:", r.Method)
	if r.Subdomain != "" {
		printfmt += fmt.Sprintf(" %s", r.Subdomain)
	}
	printfmt += fmt.Sprintf(" %s ", r.Tmpl().Src)

	if l := r.RegisteredHandlersLen(); l > 1 {
		printfmt += fmt.Sprintf("-> %s() and %d more", r.MainHandlerName, l-1)
	} else {
		printfmt += fmt.Sprintf("-> %s()", r.MainHandlerName)
	}

	// printfmt := fmt.Sprintf("%s: %s >> %s", r.Method, r.Subdomain+r.Tmpl().Src, r.MainHandlerName)
	// if l := len(r.Handlers); l > 0 {
	// 	printfmt += fmt.Sprintf(" and %d more", l)
	// }
	return printfmt // without new line.
}
853290
func TraceWrap(errin error, wraperr error) {
	if errin != nil {
		errs := NewErrorsSkip(1, wraperr, errin)
		TraceSkip(errs, 1)
	}
}
832523
func PrettyTrace(w io.Writer, trace []*Event) {
	depths := depths{}
	for _, event := range trace {
		depth := depths.GetOrSet(event.QueryID, event.ParentID)
		fmt.Fprintln(w, formatEvent(event, depth))
	}
}
901301
func Trace() CallStack {
	var pcs [512]uintptr
	n := runtime.Callers(1, pcs[:])

	frames := runtime.CallersFrames(pcs[:n])
	cs := make(CallStack, 0, n)

	// Skip extra frame retrieved just to make sure the runtime.sigpanic
	// special case is handled.
	frame, more := frames.Next()

	for more {
		frame, more = frames.Next()
		cs = append(cs, Call{frame: frame})
	}

	return cs
}
1301636
func TraceR(req *http.Request, message string, data Data) {
	TraceC(GetRequestID(req), message, data)
}
315242
func stopTracing(ctx context.Context) {
	// Handle scenario where die() is called early in startup
	if ctx == nil {
		return
	}

	if !tracing {
		return
	}

	span := opentracing.SpanFromContext(ctx)
	if span != nil {
		span.Finish()
	}

	// report all possible spans to the collector
	tracerCloser.Close()

	tracing = false
	startTracingCalled = false
	stopTracingCalled = false
}
746061
func NewArc(tags core.TagSlice) (*Arc, error) {
	arc := new(Arc)

	// set defaults (the ones which the zero value is the same are not initialized here)
	arc.Radius = 1.0
	arc.EndAngle = 360.0
	arc.ExtrusionDirection = core.Point{X: 0.0, Y: 0.0, Z: 1.0}

	arc.InitBaseEntityParser()
	arc.Update(map[int]core.TypeParser{
		39:  core.NewFloatTypeParserToVar(&arc.Thickness),
		10:  core.NewFloatTypeParserToVar(&arc.Center.X),
		20:  core.NewFloatTypeParserToVar(&arc.Center.Y),
		30:  core.NewFloatTypeParserToVar(&arc.Center.Z),
		40:  core.NewFloatTypeParserToVar(&arc.Radius),
		50:  core.NewFloatTypeParserToVar(&arc.StartAngle),
		51:  core.NewFloatTypeParserToVar(&arc.EndAngle),
		210: core.NewFloatTypeParserToVar(&arc.ExtrusionDirection.X),
		220: core.NewFloatTypeParserToVar(&arc.ExtrusionDirection.Y),
		230: core.NewFloatTypeParserToVar(&arc.ExtrusionDirection.Z),
	})

	err := arc.Parse(tags)
	return arc, err
}