Recalculate angles using equation of dipole circular motion

@param timeNew timestamp of method invoke
@return if there is a need to redraw rotation
429592
protected boolean angleRecalculate(final long timeNew) {

        // recalculate angle using simple numerical integration of motion equation
        float deltaT1 = (timeNew - time1) / 1000f;
        if (deltaT1 > TIME_DELTA_THRESHOLD) {
            deltaT1 = TIME_DELTA_THRESHOLD;
            time1 = timeNew + Math.round(TIME_DELTA_THRESHOLD * 1000);
        }
        float deltaT2 = (time1 - time2) / 1000f;
        if (deltaT2 > TIME_DELTA_THRESHOLD) {
            deltaT2 = TIME_DELTA_THRESHOLD;
        }

        // circular acceleration coefficient
        float koefI = inertiaMoment / deltaT1 / deltaT2;

        // circular velocity coefficient
        float koefAlpha = alpha / deltaT1;

        // angular momentum coefficient
        float koefk = mB * (float) (Math.sin(Math.toRadians(angle0)) * Math.cos(Math.toRadians(angle1)) -
                (Math.sin(Math.toRadians(angle1)) * Math.cos(Math.toRadians(angle0))));

        float angleNew = (koefI * (angle1 * 2f - angle2) + koefAlpha * angle1 + koefk) / (koefI + koefAlpha);

        // reassign previous iteration variables
        angle2 = angle1;
        angle1 = angleNew;
        time2 = time1;
        time1 = timeNew;

        // if angles changed less then threshold, return false - no need to redraw the view
        if (Math.abs(angleLastDrawn - angle1) < ANGLE_DELTA_THRESHOLD) {
            return false;
        } else {
            angleLastDrawn = angle1;
            return true;
        }
    }
86334
def get_rotated(self, angle):
        
        result = self.copy()
        result.rotate(angle)
        return result
26135
TimeVal time_diff(final TimeVal before, final TimeVal after_t) {
	final double bef_d = before.tv_sec + (double) before.tv_usec / 1000000;
	final double aft_d = after_t.tv_sec + (double) after_t.tv_usec / 1000000;
	final double diff_d = aft_d - bef_d;

	final TimeVal result = new TimeVal();
	result.tv_sec = (int) diff_d;
	result.tv_usec = (int) ((diff_d - result.tv_sec) * 1000000);
	return result;
    }
177473
private void calculateOffset(long currentTime, RestRequestResult result) {
        // Double-checked locking for better performance
        if ((api.getTimeOffset() != null) || (result == null) || (result.getResponse() == null)) {
            return;
        }
        synchronized (api) {
            if (api.getTimeOffset() == null) {
                // Discord sends the date in their header in the format RFC_1123_DATE_TIME
                // We use this header to calculate a possible offset between our local time and the discord time
                String date = result.getResponse().header("Date");
                if (date != null) {
                    long discordTimestamp = OffsetDateTime.parse(date, DateTimeFormatter.RFC_1123_DATE_TIME)
                            .toInstant().toEpochMilli();
                    api.setTimeOffset((discordTimestamp - currentTime));
                    logger.debug("Calculated an offset of {} to the Discord time.", api::getTimeOffset);
                }
            }
        }
    }
289338
@Override
    public ChronoZonedDateTime<D> with(TemporalField field, long newValue) {
        if (field instanceof ChronoField) {
            ChronoField f = (ChronoField) field;
            switch (f) {
                case INSTANT_SECONDS: return plus(newValue - toEpochSecond(), SECONDS);
                case OFFSET_SECONDS: {
                    ZoneOffset offset = ZoneOffset.ofTotalSeconds(f.checkValidIntValue(newValue));
                    return create(dateTime.toInstant(offset), zone);
                }
            }
            return ofBest(dateTime.with(field, newValue), zone, offset);
        }
        return ChronoZonedDateTimeImpl.ensureValid(getChronology(), field.adjustInto(this, newValue));
    }
33747
def rotated(self, angle_degrees_ccw):
        """"""
        angle = angle_degrees_ccw / 180.0 * pi
        c, s = cos(angle), sin(angle)
        return self @ PdfMatrix((c, s, -s, c, 0, 0))
904884
public void rotateByAxis(float angle, float x, float y, float z) {
        NativeTransform.rotateByAxis(getNative(), angle * TO_RADIANS, x, y, z);
    }
1283076
def fix_repeat_dt(dt_list, offset_s=0.001):
    
    idx = (np.diff(dt_list) == timedelta(0))
    while np.any(idx):
        dt_list[idx.nonzero()[0] + 1] += timedelta(seconds=offset_s)
        idx = (np.diff(dt_list) == timedelta(0))
    return dt_list
60709
@SuppressWarnings("checkstyle:magicnumber")
	public void setRotation(double angle) {
		final double[] tmpScale = new double[3];
		final double[] tmpRot = new double[9];
		getScaleRotate2x2(tmpScale, tmpRot);
		final double cos = Math.cos(angle);
		final double sin = Math.sin(angle);
		// R * S
		this.m00 = tmpScale[0] * cos;
		this.m01 = tmpScale[1] * -sin;
		this.m10 = tmpScale[0] * sin;
		this.m11 = tmpScale[1] * cos;
		// S * R
		//		this.m00 = tmp_scale[0] * cos;
		//		this.m01 = tmp_scale[0] * -sin;
		//		this.m10 = tmp_scale[1] * sin;
		//		this.m11 = tmp_scale[1] * cos;
	}
1006424
public void refreshCurve() {
//        System.out.println("Curve refreshing");
		needsRefresh = false;

        double lengthx = end.x - start.x;
        double lengthy = end.y - start.y;
        double centerx = ((double) (start.x + end.x)) / 2.0;
        double centery = ((double) (start.y + end.y)) / 2.0;

        double length = Math.sqrt(lengthx * lengthx + lengthy * lengthy);
        double factorx = length == 0.0 ? 0.0 : lengthx / length;
        double factory = length == 0.0 ? 0.0 : lengthy / length;

        control.x = (int) (centerx + curvy * HEIGHT * factory);
        control.y = (int) (centery - curvy * HEIGHT * factorx);
        high.x = (int) (centerx + curvy * HEIGHT * factory / 2.0);
        high.y = (int) (centery - curvy * HEIGHT * factorx / 2.0);

        curve.setCurve((float) start.x, (float) start.y, (float) control.x,
                (float) control.y, (float) end.x, (float) end.y);

        affineToText = new AffineTransform();
        affineToText.translate(high.x, high.y);
        affineToText.rotate(Math.atan2(lengthy, lengthx));
        if (end.x < start.x)
            affineToText.rotate(Math.PI);
	}
149603
@Override
    public void getOffset(long date, boolean local, int[] offsets) {
        synchronized (javacal) {
            if (local) {
                int fields[] = new int[6];
                Grego.timeToFields(date, fields);
                int hour, min, sec, mil;
                int tmp = fields[5];
                mil = tmp % 1000;
                tmp /= 1000;
                sec = tmp % 60;
                tmp /= 60;
                min = tmp % 60;
                hour = tmp / 60;
                javacal.clear();
                javacal.set(fields[0], fields[1], fields[2], hour, min, sec);
                javacal.set(java.util.Calendar.MILLISECOND, mil);

                int doy1, hour1, min1, sec1, mil1;
                doy1 = javacal.get(java.util.Calendar.DAY_OF_YEAR);
                hour1 = javacal.get(java.util.Calendar.HOUR_OF_DAY);
                min1 = javacal.get(java.util.Calendar.MINUTE);
                sec1 = javacal.get(java.util.Calendar.SECOND);
                mil1 = javacal.get(java.util.Calendar.MILLISECOND);

                if (fields[4] != doy1 || hour != hour1 || min != min1 || sec != sec1 || mil != mil1) {
                    // Calendar field(s) were changed due to the adjustment for non-existing time
                    // Note: This code does not support non-existing local time at year boundary properly.
                    // But, it should work fine for real timezones.
                    int dayDelta = Math.abs(doy1 - fields[4]) > 1 ? 1 : doy1 - fields[4];
                    int delta = ((((dayDelta * 24) + hour1 - hour) * 60 + min1 - min) * 60 + sec1 - sec) * 1000 + mil1 - mil;

                    // In this case, we use the offsets before the transition
                   javacal.setTimeInMillis(javacal.getTimeInMillis() - delta - 1);
                }
            } else {
                javacal.setTimeInMillis(date);
            }
            offsets[0] = javacal.get(java.util.Calendar.ZONE_OFFSET);
            offsets[1] = javacal.get(java.util.Calendar.DST_OFFSET);
        }
    }
373059
public SliceValue getValueForAngle(int angle, SelectedValue selectedValue) {
        final PieChartData data = dataProvider.getPieChartData();
        final float touchAngle = (angle - rotation + 360f) % 360f;
        final float sliceScale = 360f / maxSum;
        float lastAngle = 0f;
        int sliceIndex = 0;
        for (SliceValue sliceValue : data.getValues()) {
            final float tempAngle = Math.abs(sliceValue.getValue()) * sliceScale;
            if (touchAngle >= lastAngle) {
                if (null != selectedValue) {
                    selectedValue.set(sliceIndex, sliceIndex, SelectedValueType.NONE);
                }
                return sliceValue;
            }
            lastAngle += tempAngle;
            ++sliceIndex;
        }
        return null;
    }
111859
function(timeStep){
        switch(this.type){
            case this.BODY_STATIC:
                this.linearVelocity.init();
                this.angularVelocity.init();
                // ONLY FOR TEST
                if(this.controlPos){
                    this.position.copy(this.newPosition);
                    this.controlPos = false;
                }
                if(this.controlRot){
                    this.orientation.copy(this.newOrientation);
                    this.controlRot = false;
                }
                /*this.linearVelocity.x=0;
                this.linearVelocity.y=0;
                this.linearVelocity.z=0;
                this.angularVelocity.x=0;
                this.angularVelocity.y=0;
                this.angularVelocity.z=0;*/
            break;
            case this.BODY_DYNAMIC:

                if(this.controlPos){
                    this.angularVelocity.init();
                    this.linearVelocity.init();
                    this.linearVelocity.x = (this.newPosition.x - this.position.x)/timeStep;
                    this.linearVelocity.y = (this.newPosition.y - this.position.y)/timeStep;
                    this.linearVelocity.z = (this.newPosition.z - this.position.z)/timeStep;
                    this.controlPos = false;
                }
                if(this.controlRot){
                    this.angularVelocity.init();
                    this.orientation.copy(this.newOrientation);

                    //var t=timeStep//*0.5;
                    //var q = new OIMO.Quat();
                    //q.sub(this.newOrientation, this.orientation);
                    //q.normalize(q);
                    /*q.s = (this.newOrientation.s - this.orientation.s)/t;
                    q.x = (this.newOrientation.x - this.orientation.x)/t;
                    q.y = (this.newOrientation.y - this.orientation.y)/t;
                    q.z = (this.newOrientation.z - this.orientation.z)/t;*/

                    //this.angularVelocity.applyQuaternion(q);
                    //this.angularVelocity.x = this.angularVelocity.x/t;
                    //this.angularVelocity.y = this.angularVelocity.y/t;
                    //this.angularVelocity.z = this.angularVelocity.z/t;

                    this.controlRot = false;
                }

                this.position.addTime(this.linearVelocity, timeStep);
                this.orientation.addTime(this.angularVelocity, timeStep);

            break;
            default:
                throw new Error("Invalid type.");
        }
        this.syncShapes();
    }
1367396
public Instant getNextExecutionTimeAfter(Instant now) {
        OffsetTime timeOfDay = OffsetTime.from(TIME_OF_DAY_FORMAT.parse(getTimeOfDay()));

        // The time of the next run is based on the time past midnight UTC relative to the current time
        Instant nextExecTime = now.atOffset(ZoneOffset.UTC).with(timeOfDay).toInstant();

        // If the first execution would have been for earlier today move to the next execution.
        while (nextExecTime.isBefore(now)) {
            nextExecTime = nextExecTime.plus(Duration.ofDays(1));
        }

        return nextExecTime;
    }
930877
function(angle) {
    this.dir = (this.dir + angle + circle) % circle;

    // Calculate the rotation vector and update the orientation of the listener.
    var x = Math.cos(this.dir);
    var y = 0;
    var z = Math.sin(this.dir);
    Howler.orientation(x, y, z, 0, 1, 0);
  }
864241
private void calcCurrentItem() {
        int pointerAngle;

        // calculate the correct pointer angle, depending on clockwise drawing or not
        if(mOpenClockwise) {
            pointerAngle = (mIndicatorAngle + 360 - mPieRotation) % 360;
        }
        else {
            pointerAngle = (mIndicatorAngle + 180 + mPieRotation) % 360;
        }

        for (int i = 0; i < mPieData.size(); ++i) {
            PieModel model = mPieData.get(i);
            if (model.getStartAngle() <= pointerAngle && pointerAngle <= model.getEndAngle()) {
                if (i != mCurrentItem) {
                    setCurrentItem(i, false);
                }
                break;
            }
        }
    }
751075
public double totalTime(TimeUnit unit) {
        T obj2 = ref.get();
        if (obj2 != null) {
            double prevLast = lastTime;
            lastTime = Math.max(TimeUtils.convert(totalTimeFunction.applyAsDouble(obj2), totalTimeFunctionUnit, baseTimeUnit()), 0);
            total.getCurrent().add(lastTime - prevLast);
        }
        return TimeUtils.convert(total.poll(), baseTimeUnit(), unit);
    }