diff --git a/demoProjects/Drag2D/app/build.gradle b/demoProjects/Drag2D/app/build.gradle
index e8007d7e3..ccd487795 100644
--- a/demoProjects/Drag2D/app/build.gradle
+++ b/demoProjects/Drag2D/app/build.gradle
@@ -32,8 +32,4 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
- testImplementation 'junit:junit:4.13.2'
- androidTestImplementation 'androidx.test.ext:junit:1.1.5'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
\ No newline at end of file
diff --git a/demoProjects/Drag2D/app/src/androidTest/java/android/support/drag2d/ExampleInstrumentedTest.java b/demoProjects/Drag2D/app/src/androidTest/java/android/support/drag2d/ExampleInstrumentedTest.java
deleted file mode 100644
index 27221df44..000000000
--- a/demoProjects/Drag2D/app/src/androidTest/java/android/support/drag2d/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.support.drag2d;
-
-import android.content.Context;
-
-import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
- assertEquals("android.support.drag2d", appContext.getPackageName());
- }
-}
\ No newline at end of file
diff --git a/demoProjects/Drag2D/app/src/main/AndroidManifest.xml b/demoProjects/Drag2D/app/src/main/AndroidManifest.xml
index 4b2795d4c..72e03da37 100644
--- a/demoProjects/Drag2D/app/src/main/AndroidManifest.xml
+++ b/demoProjects/Drag2D/app/src/main/AndroidManifest.xml
@@ -4,10 +4,8 @@
@@ -20,6 +18,15 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/demoProjects/Drag2D/app/src/main/java/android/support/drag2d/DragCardActivity.java b/demoProjects/Drag2D/app/src/main/java/android/support/drag2d/DragCardActivity.java
new file mode 100644
index 000000000..146944362
--- /dev/null
+++ b/demoProjects/Drag2D/app/src/main/java/android/support/drag2d/DragCardActivity.java
@@ -0,0 +1,331 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.support.drag2d;
+
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.os.SystemClock;
+import android.support.drag2d.lib.MaterialEasing;
+import android.support.drag2d.lib.MaterialVelocity;
+import android.support.drag2d.lib.Velocity2D;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.VelocityTracker;
+import android.view.View;
+import android.view.Window;
+import android.widget.LinearLayout;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.AppCompatButton;
+import androidx.core.content.res.ResourcesCompat;
+import androidx.appcompat.widget.AppCompatSeekBar;
+
+import com.google.android.material.slider.Slider;
+
+import java.text.DecimalFormat;
+
+
+public class DragCardActivity extends AppCompatActivity {
+ int backgroundColor = 0xFF000000 | (200 * 256 + 250) * 256 + 200;
+ static String[] sEasingNames = {
+ "DECELERATE",
+ "LINEAR",
+ "OVERSHOOT",
+ "SINE",
+ "CUBIC",
+ "QUINT",
+ "CIRC",
+ "QUAD",
+ "QUART",
+ "EXPO",
+ "BACK",
+ "ELASTIC",
+ "BOUNCE"
+ };
+ static MaterialVelocity.Easing[] sEasings = {
+ MaterialEasing.DECELERATE,
+ MaterialEasing.LINEAR,
+ MaterialEasing.OVERSHOOT,
+ MaterialEasing.EASE_OUT_SINE,
+ MaterialEasing.EASE_OUT_CUBIC,
+ MaterialEasing.EASE_OUT_QUINT,
+ MaterialEasing.EASE_OUT_CIRC,
+ MaterialEasing.EASE_OUT_QUAD,
+ MaterialEasing.EASE_OUT_QUART,
+ MaterialEasing.EASE_OUT_EXPO,
+ MaterialEasing.EASE_OUT_BACK,
+ MaterialEasing.EASE_OUT_ELASTIC,
+ MaterialEasing.EASE_OUT_BOUNCE
+ };
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ requestWindowFeature(Window.FEATURE_ACTION_BAR);
+ LinearLayout topCol = new LinearLayout(this);
+ LinearLayout row = new LinearLayout(this);
+ LinearLayout col = new LinearLayout(this);
+ topCol.setOrientation(LinearLayout.VERTICAL);
+ col.setOrientation(LinearLayout.VERTICAL);
+ ScrollView scrollView = new ScrollView(this);
+ CardMover m = new CardMover(this);
+ AppCompatButton[]buttons = new AppCompatButton[sEasingNames.length];
+ for (int i = 0; i < sEasingNames.length; i++) {
+ AppCompatButton b = new AppCompatButton(this);
+ buttons[i] = b;
+ b.setText(sEasingNames[i]);
+ int mode = i;
+ Drawable d = b.getBackground();
+ d = d.mutate();
+ d.setTint(0xffAA88AA);
+ b.setBackgroundDrawable(d);
+ b.setPadding(1, 1, 5, 5);
+ col.addView(b);
+ b.setOnClickListener(c -> {
+ for (int j = 0; j < buttons.length; j++) {
+ Drawable draw = buttons[j].getBackground();
+ draw = draw.mutate();
+ draw.setTint((mode == j)?0xff328855:0xffAA88AA);
+ buttons[j].setBackgroundDrawable(draw);
+ }
+
+ m.setEasing(sEasings[mode]);
+ });
+
+ }
+ String[] name = {"Max V: ", "Max A: ", "time:"};
+ float[] min = {400, 400, 0.1f};
+ float[] max = {8000, 8000, 10f};
+ float[] val = {800, 800, 0.2f};
+
+ DecimalFormat df = new DecimalFormat("##0.0");
+ for (int i = 0; i < name.length; i++) {
+ int sno = i;
+ LinearLayout slidePack = new LinearLayout(this);
+
+ Slider slider = new Slider(this);
+ TextView tv = new TextView(this);
+ tv.setWidth(340);
+ tv.setText(name[sno] + min[sno]);
+ slidePack.addView(tv);
+ slidePack.addView(slider);
+
+ slider.setValue(val[sno]);
+ slider.setValueTo(max[sno]);
+ slider.setValueFrom(min[sno]);
+ slider.addOnChangeListener(new Slider.OnChangeListener() {
+ @Override
+ public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
+ float v = value;
+ tv.setText(name[sno] + df.format(v));
+ m.setParam(sno, v);
+ }
+ });
+ topCol.addView(slidePack);
+
+ }
+ AppCompatButton b = new AppCompatButton(this);
+ b.setText("plot Position");
+ b.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
+ col.addView(b);
+ Drawable d = b.getBackground();
+ d = d.mutate();
+ d.setTint(0xff328832);
+ b.setBackgroundDrawable(d);
+ b.setOnClickListener(c -> {
+ m.mGraphMode = !m.mGraphMode;
+ b.setText("plot " + (m.mGraphMode ? "velocity" : "Position"));
+ });
+
+ col.setBackgroundColor(backgroundColor);
+ scrollView.addView(col);
+ row.addView(scrollView);
+ row.addView(m);
+ topCol.addView(row);
+ setContentView(topCol);
+
+ }
+
+ static class CardMover extends View {
+ public boolean mGraphMode = false;
+ Drawable ball;
+ VelocityTracker velocityTracker = VelocityTracker.obtain();
+ Velocity2D velocity2D = new Velocity2D();
+ int mCardX = -30;
+ int mCardY = 0;
+ Paint mCardPaint = new Paint();
+ MaterialVelocity.Easing easing = null;
+ float[] points = new float[10000];
+ Paint paint = new Paint();
+ Paint paintDot = new Paint();
+ private float mDuration;
+
+
+ public CardMover(Context context) {
+ super(context);
+ setup(context);
+ }
+
+ public CardMover(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ setup(context);
+ }
+
+ public CardMover(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ setup(context);
+ }
+
+
+ void setup(Context context) {
+ ball = ResourcesCompat.getDrawable(context.getResources(), R.drawable.volleyball, null);
+ paint.setStrokeWidth(3);
+ paintDot.setColor(Color.RED);
+ mCardPaint.setStyle(Paint.Style.FILL_AND_STROKE);
+ mCardPaint.setColor(0x55FF8800);
+ }
+
+ public void setEasing(MaterialVelocity.Easing easing) {
+ this.easing = easing;
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ canvas.drawRGB(230, 210, 200);
+ int rounding = touchDown ? 128 : 0;
+ if (startAnimationTime != 0) {
+
+ long timeMillis = SystemClock.uptimeMillis() - startAnimationTime;
+ float time = timeMillis / 1000f;
+ mCardX = (int) velocity2D.getX(time);
+ mCardY = (int) velocity2D.getY(time);
+
+ if (velocity2D.isStillMoving(time)) {
+ rounding = 48;
+ invalidate();
+ } else {
+ startAnimationTime = 0;
+ }
+ canvas.drawLines(points, paint);
+ int xPos = velocity2D.getPointOffsetX(points.length, time / mDuration);
+ int yPos = velocity2D.getPointOffsetY(points.length, time / mDuration);
+ float x = points[xPos], y = points[xPos + 1];
+ canvas.drawRoundRect(x - 10, y - 10, x + 10, y + 10, 20, 20, paintDot);
+ x = points[yPos];
+ y = points[yPos + 1];
+ canvas.drawRoundRect(x - 10, y - 10, x + 10, y + 10, 20, 20, paintDot);
+ }
+ // draw card
+
+ canvas.drawRoundRect(mCardX, mCardY, mCardX + getWidth() / 2, getHeight() + mCardY, rounding, rounding, mCardPaint);
+ int scale = 128;
+ int ballX = mCardX + getWidth() / 4 - scale/2;
+ int ballY = mCardY + getHeight() / 2 - scale/2;
+ ball.setBounds(ballX, ballY, ballX + scale, ballY + scale);
+ ball.setTint(Color.CYAN);
+ ball.draw(canvas);
+ }
+
+ float touchDownX;
+ float touchDownY;
+ float touchDeltaX, touchDeltaY;
+ int ballDownX, ballDownY;
+ long startAnimationTime;
+ boolean touchDown = false;
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ velocityTracker.addMovement(event);
+ switch (event.getAction()) {
+
+ case MotionEvent.ACTION_DOWN:
+ startAnimationTime = 0;
+ touchDownX = event.getX();
+ touchDownY = event.getY();
+ ballDownX = mCardX;
+ ballDownY = mCardY;
+ touchDown = true;
+ break;
+
+ case MotionEvent.ACTION_MOVE:
+ touchDeltaX = event.getX() - touchDownX;
+ touchDeltaY = event.getY() - touchDownY;
+ mCardX = (int) (ballDownX + touchDeltaX);
+ mCardY = (int) (ballDownY + touchDeltaY);
+ int slop = 300;
+ mCardY = Math.max(-slop, Math.min(slop, mCardY));
+ mCardY = (int) softClamp(mCardY, -slop, +slop);
+ invalidate();
+
+ break;
+ case MotionEvent.ACTION_UP:
+ velocityTracker.computeCurrentVelocity(1000);
+ float velocityX = velocityTracker.getXVelocity();
+ float velocityY = velocityTracker.getYVelocity();
+ startAnimationTime = event.getEventTime();
+ touchDown = false;
+ boolean dir = mCardX + velocityX < getWidth() / 4;
+ velocity2D.configure(mCardX, mCardY,
+ velocityX, 0,
+ dir ? 0 : getWidth() / 2, 0,
+ duration, maxV, maxA,
+ easing);
+ velocity2D.getCurves(points, getWidth(), getHeight(), mGraphMode);
+ mDuration = velocity2D.getDuration();
+ invalidate();
+ break;
+
+ }
+ return true;
+ }
+
+ float maxV = 800;
+ float maxA = 800;
+ float duration = 0.2f;
+
+ public void setParam(int param, float v) {
+ switch (param) {
+ case 0:
+ maxV = v;
+ break;
+ case 1:
+ maxA = v;
+ break;
+ case 2:
+ duration = v;
+ }
+ }
+ }
+
+ public static float softClamp(float x, float min, float max) {
+ float halfWidth = (max - min) / 2;
+ x = (x - (min + max) / 2) / halfWidth;
+
+ return (max + min) / 2 + halfWidth * (float) (1 / (1 + Math.exp(-x)) - 0.5f);
+
+ }
+}
\ No newline at end of file
diff --git a/demoProjects/Drag2D/app/src/main/java/android/support/drag2d/MainActivity.java b/demoProjects/Drag2D/app/src/main/java/android/support/drag2d/MainActivity.java
index 311d99acb..c1f6cd7dd 100644
--- a/demoProjects/Drag2D/app/src/main/java/android/support/drag2d/MainActivity.java
+++ b/demoProjects/Drag2D/app/src/main/java/android/support/drag2d/MainActivity.java
@@ -18,9 +18,11 @@
import android.content.Context;
+import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.SystemClock;
@@ -47,16 +49,16 @@ public class MainActivity extends AppCompatActivity {
"DECELERATE",
"LINEAR",
"OVERSHOOT",
- "EASE_OUT_SINE",
- "EASE_OUT_CUBIC",
- "EASE_OUT_QUINT",
- "EASE_OUT_CIRC",
- "EASE_OUT_QUAD",
- "EASE_OUT_QUART",
- "EASE_OUT_EXPO",
- "EASE_OUT_BACK",
- "EASE_OUT_ELASTIC",
- "EASE_OUT_BOUNCE"
+ "SINE",
+ "CUBIC",
+ "QUINT",
+ "CIRC",
+ "QUAD",
+ "QUART",
+ "EXPO",
+ "BACK",
+ "ELASTIC",
+ "BOUNCE"
};
static MaterialVelocity.Easing[] sEasings = {
MaterialEasing.DECELERATE,
@@ -83,28 +85,56 @@ protected void onCreate(Bundle savedInstanceState) {
col.setOrientation(LinearLayout.VERTICAL);
ScrollView scrollView = new ScrollView(this);
BallMover m = new BallMover(this);
+ AppCompatButton[]buttons = new AppCompatButton[sEasingNames.length];
+
for (int i = 0; i < sEasingNames.length; i++) {
AppCompatButton b = new AppCompatButton(this);
+ buttons[i] = b;
b.setText(sEasingNames[i]);
- MaterialVelocity.Easing easing = sEasings[i];
- b.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
-
+ int mode = i;
+ Drawable d = b.getBackground();
+ d = d.mutate();
+ d.setTint(0xffAAAAAA);
+ b.setBackgroundDrawable(d);
b.setPadding(1, 1, 5, 5);
col.addView(b);
b.setOnClickListener(c -> {
- m.setEasing(easing);
+ for (int j = 0; j < buttons.length; j++) {
+ Drawable draw = buttons[j].getBackground();
+ draw = draw.mutate();
+ draw.setTint((mode == j)?Color.CYAN:0xffAAAAAA);
+ buttons[j].setBackgroundDrawable(draw);
+ }
+
+ m.setEasing(sEasings[mode]);
});
}
AppCompatButton b = new AppCompatButton(this);
- b.setText("graph mode");
+ // mode
+ b.setText("plot Position");
b.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
col.addView(b);
+ Drawable d = b.getBackground();
+ d = d.mutate();
+ d.setTint(0xff328832);
+ b.setBackgroundDrawable(d);
b.setOnClickListener(c -> {
m.mGraphMode = !m.mGraphMode;
+ b.setText("plot " + (m.mGraphMode ? "velocity" : "Position"));
+ });
+ // mode
+ AppCompatButton app = new AppCompatButton(this);
+ app.setText("card demo...");
+ app.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
+ col.addView(app);
+ app.setOnClickListener(c -> {
+ Intent intent = new Intent(this, DragCardActivity.class);
+ startActivity(intent);
});
+
col.setBackgroundColor(backgroundColor);
scrollView.addView(col);
row.addView(scrollView);
diff --git a/demoProjects/Drag2D/app/src/main/java/android/support/drag2d/lib/MaterialVelocity.java b/demoProjects/Drag2D/app/src/main/java/android/support/drag2d/lib/MaterialVelocity.java
index dcd01ac98..40e522ae7 100644
--- a/demoProjects/Drag2D/app/src/main/java/android/support/drag2d/lib/MaterialVelocity.java
+++ b/demoProjects/Drag2D/app/src/main/java/android/support/drag2d/lib/MaterialVelocity.java
@@ -158,6 +158,9 @@ public interface Easing {
public void config(float currentPos, float destination, float currentVelocity,
float maxTime, float maxAcceleration, float maxVelocity, Easing easing) {
+ if (currentPos == destination) {
+ currentPos += 1;
+ }
mStartPos = currentPos;
mEndPos = destination;
@@ -180,8 +183,8 @@ public void config(float currentPos, float destination, float currentVelocity,
if (!rampDown(currentPos, destination, currentVelocity, maxTime)) {
if (!(oneDimension && cruseThenRampDown(currentPos, destination, currentVelocity, maxTime, maxA, maxV))) {
- if (!rampUpRampDown(currentPos, destination, currentVelocity, maxA, maxV)) {
- rampUpCruseRampDown(currentPos, destination, currentVelocity, maxA, maxV);
+ if (!rampUpRampDown(currentPos, destination, currentVelocity, maxA, maxV, maxTime)) {
+ rampUpCruseRampDown(currentPos, destination, currentVelocity, maxA, maxV, maxTime);
}
}
}
@@ -225,9 +228,9 @@ private boolean cruseThenRampDown(float currentPos, float destination, float cur
}
private boolean rampUpRampDown(float currentPos, float destination, float currentVelocity,
- float maxA, float maxVelocity) {
+ float maxA, float maxVelocity, float maxTime) {
float peak_v = Math.signum(maxA) * (float) Math.sqrt(maxA * (destination - currentPos) + currentVelocity * currentVelocity / 2);
-
+ System.out.println(">>>>>>>>> peak "+peak_v + " " + maxVelocity);
if (maxVelocity / peak_v > 1) {
float t1 = (peak_v - currentVelocity) / maxA;
float d1 = (peak_v + currentVelocity) * t1 / 2 + currentPos;
@@ -236,25 +239,73 @@ private boolean rampUpRampDown(float currentPos, float destination, float curren
mStage[0].setUp(currentVelocity, currentPos, 0, peak_v, d1, t1);
mStage[1].setUp(peak_v, d1, t1, 0, destination, t2 + t1);
mDuration = t2 + t1;
+ if (mDuration > maxTime) {
+ return false;
+ }
+ System.out.println(">>>>>>>>> rampUpRampDown "+mDuration+ " "+maxTime);
+
+ if (mDuration < maxTime/2) {
+
+ t1 = mDuration/2;
+ t2 = t1;
+ peak_v = (2*(destination-currentPos) / t1 - currentVelocity)/2;
+ d1 = (peak_v + currentVelocity) * t1 / 2 + currentPos;
+
+ mNumberOfStages = 2;
+ mStage[0].setUp(currentVelocity, currentPos, 0, peak_v, d1, t1);
+ mStage[1].setUp(peak_v, d1, t1, 0, destination, t2 + t1);
+ mDuration = t2 + t1;
+ System.out.println(">>>>>>>>>f rampUpRampDown "+mDuration+ " "+maxTime);
+ System.out.println(">>>>>>>>>f peak "+peak_v + " " + maxVelocity);
+
+ if (mDuration > maxTime) {
+ System.out.println(" fail ");
+ return false;
+ }
+ }
+
return true;
}
return false;
}
- private void rampUpCruseRampDown(float currentPos, float destination, float currentVelocity,
- float maxA, float maxV) {
- float t1 = (maxV - currentVelocity) / maxA;
- float d1 = (maxV + currentVelocity) * t1 / 2 + currentPos;
- float t3 = maxV / maxA;
- float d3 = (maxV) * t3 / 2;
- float d2 = destination - d1 - d3;
- float t2 = d2 / maxV;
+ private void rampUpCruseRampDown(float currentPos, float destination, float currentVelocity,
+ float maxA, float maxV, float maxTime) {
+// float t1 = (maxV - currentVelocity) / maxA;
+// float d1 = (maxV + currentVelocity) * t1 / 2 + currentPos;
+// float t3 = maxV / maxA;
+// float d3 = (maxV) * t3 / 2;
+// float d2 = destination - d1 - d3;
+// float t2 = d2 / maxV;
+//
+// mNumberOfStages = 3;
+// mStage[0].setUp(currentVelocity, currentPos, 0, maxV, d1, t1);
+// mStage[1].setUp(maxV, d1, t1, maxV, d2 + d1, t2 + t1);
+// mStage[2].setUp(maxV, d1 + d2, t1 + t2, 0, destination, t2 + t1 + t3);
+// mDuration = t3 + t2 + t1;
+ float t1 = maxTime/3;
+ float t2 = t1 * 2;
+ float duration = maxTime;
+ float distance = destination - currentPos;
+ float dt1 = t1;
+ float dt2 = t2 - t1;
+ float dt3 = duration - t2;
+ float v1 = (2 * distance - currentVelocity * dt1) / (dt1 + 2 * dt2 + dt3);
+ float peakV1 = v1, peakV2 = v1;
+ mDuration = duration;
+ float d1 = (currentVelocity + peakV1) * t1 / 2;
+ float d2 = (peakV1 + peakV2) * (t2 - t1) / 2;
mNumberOfStages = 3;
- mStage[0].setUp(currentVelocity, currentPos, 0, maxV, d1, t1);
- mStage[1].setUp(maxV, d1, t1, maxV, d2 + d1, t2 + t1);
- mStage[2].setUp(maxV, d1 + d2, t1 + t2, 0, destination, t2 + t1 + t3);
- mDuration = t3 + t2 + t1;
+ float acc = (v1-currentVelocity)/t1;
+ float dec = (v1)/dt3;
+ System.out.println(" >>>>>> "+acc+" / "+v1+" \\ "+ dec);
+
+
+ mStage[0].setUp(currentVelocity, currentPos, 0, peakV1, currentPos + d1, t1);
+ mStage[1].setUp(peakV1, currentPos + d1, t1, peakV2, currentPos + d1 + d2, t2);
+ mStage[2].setUp(peakV2, currentPos + d1 + d2, t2, 0, destination, duration);
+ mDuration = duration;
}
diff --git a/demoProjects/Drag2D/app/src/main/res/values-night/themes.xml b/demoProjects/Drag2D/app/src/main/res/values-night/themes.xml
deleted file mode 100644
index a22fc83e8..000000000
--- a/demoProjects/Drag2D/app/src/main/res/values-night/themes.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/demoProjects/Drag2D/app/src/main/res/values/colors.xml b/demoProjects/Drag2D/app/src/main/res/values/colors.xml
deleted file mode 100644
index f8c6127d3..000000000
--- a/demoProjects/Drag2D/app/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
- #FFBB86FC
- #FF6200EE
- #FF3700B3
- #FF03DAC5
- #FF018786
- #FF000000
- #FFFFFFFF
-
\ No newline at end of file
diff --git a/demoProjects/Drag2D/app/src/main/res/values/strings.xml b/demoProjects/Drag2D/app/src/main/res/values/strings.xml
deleted file mode 100644
index 69597d735..000000000
--- a/demoProjects/Drag2D/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- Drag2D
-
\ No newline at end of file
diff --git a/demoProjects/Drag2D/app/src/main/res/values/themes.xml b/demoProjects/Drag2D/app/src/main/res/values/themes.xml
index 35c55bf04..1276cbad8 100644
--- a/demoProjects/Drag2D/app/src/main/res/values/themes.xml
+++ b/demoProjects/Drag2D/app/src/main/res/values/themes.xml
@@ -1,16 +1,5 @@
\ No newline at end of file
diff --git a/demoProjects/Drag2D/app/src/main/res/xml/backup_rules.xml b/demoProjects/Drag2D/app/src/main/res/xml/backup_rules.xml
deleted file mode 100644
index fa0f996d2..000000000
--- a/demoProjects/Drag2D/app/src/main/res/xml/backup_rules.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/demoProjects/Drag2D/app/src/main/res/xml/data_extraction_rules.xml b/demoProjects/Drag2D/app/src/main/res/xml/data_extraction_rules.xml
deleted file mode 100644
index 9ee9997b0..000000000
--- a/demoProjects/Drag2D/app/src/main/res/xml/data_extraction_rules.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demoProjects/Drag2D/app/src/test/java/android/support/drag2d/ExampleUnitTest.java b/demoProjects/Drag2D/app/src/test/java/android/support/drag2d/ExampleUnitTest.java
deleted file mode 100644
index 7d7d4226b..000000000
--- a/demoProjects/Drag2D/app/src/test/java/android/support/drag2d/ExampleUnitTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package android.support.drag2d;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file