本文整理汇总了Java中com.thalmic.myo.Quaternion类的典型用法代码示例。如果您正苦于以下问题:Java Quaternion类的具体用法?Java Quaternion怎么用?Java Quaternion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Quaternion类属于com.thalmic.myo包,在下文中一共展示了Quaternion类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onOrientationData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long l, Quaternion quaternion)
{
orientationW = quaternion.w();
orientationX = quaternion.x();
orientationY = quaternion.y();
orientationZ = quaternion.z();
float roll = (float) Math.atan2(2.0 * (quaternion.w() * quaternion.x() + quaternion.y() * quaternion.z()), 1.0 - 2.0 * (quaternion.x() * quaternion.x() + quaternion.y() * quaternion.y()));
float pitch = (float) Math.asin(Math.max(-1.0, Math.min(1.0, 2.0 * (quaternion.w() * quaternion.y() - quaternion.z() * quaternion.x()))));
float yaw = (float) Math.atan2(2.0 * (quaternion.w() * quaternion.z() + quaternion.x() * quaternion.y()), 1.0 - 2.0 * (quaternion.y() * quaternion.y() + quaternion.z() * quaternion.z()));
// Convert the floating point angles in radians to a scale from 0 to 18.
rollW = (int) ((roll + (float) Math.PI) / (Math.PI * 2.0) * 18);
pitchW = (int) ((pitch + (float) Math.PI / 2.0) / Math.PI * 18);
yawW = (int) ((yaw + (float) Math.PI) / (Math.PI * 2.0) * 18);
}
开发者ID:hcmlab,项目名称:ssj,代码行数:18,代码来源:MyoListener.java
示例2: onOrientationData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long timestamp, Quaternion rotation) {
// Calculate Euler angles (roll, pitch, and yaw) from the quaternion.
double roll = Math.toDegrees(Quaternion.roll(rotation));
double pitch = Math.toDegrees(Quaternion.pitch(rotation));
double yaw = Math.toDegrees(Quaternion.yaw(rotation));
// Adjust roll and pitch for the orientation of the Myo on the arm.
if (myo.getXDirection() == XDirection.TOWARD_ELBOW) {
roll *= -1;
pitch *= -1;
}
MyoOrientationDataFrame frame = new MyoOrientationDataFrame(MyoSensor.this, timestamp, roll, pitch, yaw);
sendNewData(frame);
}
开发者ID:gradlman,项目名称:SensorLib,代码行数:17,代码来源:MyoSensor.java
示例3: onOrientationData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long timestamp, Quaternion rotation) {
Quaternion normalized = rotation.normalized();
double roll = Math.atan2(2.0f * (normalized.getW() * normalized.getX() + normalized.getY() * normalized.getZ()),
1.0f - 2.0f * (normalized.getX() * normalized.getX() + normalized.getY() * normalized.getY()));
double pitch = Math.asin(2.0f * (normalized.getW() * normalized.getY() - normalized.getZ() * normalized.getX()));
double yaw = Math.atan2(2.0f * (normalized.getW() * normalized.getZ() + normalized.getX() * normalized.getY()),
1.0f - 2.0f * (normalized.getY() * normalized.getY() + normalized.getZ() * normalized.getZ()));
rollW = Math.round((roll + Math.PI) / (Math.PI * 2.0) * scale);
pitchW = Math.round((pitch + Math.PI / 2.0) / Math.PI * scale);
yawW = Math.round((yaw + Math.PI) / (Math.PI * 2.0) * scale);
delta = (myodata.roll - rollW != 0) || (myodata.pitch - pitchW != 0) || (myodata.yaw - yawW != 0);
if (delta) {
myodata.roll = rollW;
myodata.pitch = pitchW;
myodata.yaw = yawW;
myodata.timestamp = timestamp;
invoke("publishMyoData", myodata);
}
}
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:27,代码来源:MyoThalmic.java
示例4: updateValues
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
private void updateValues(Quaternion rotation) {
// Calculate Euler angles (roll, pitch, and yaw) from the quaternion.
float roll = (float) Math.toDegrees(Quaternion.roll(rotation));
float pitch = (float) Math.toDegrees(Quaternion.pitch(rotation));
float yaw = (float) Math.toDegrees(Quaternion.yaw(rotation));
// Adjust roll and pitch for the orientation of the Myo on the arm.
if (mXDirection == XDirection.TOWARD_ELBOW) {
roll *= -1;
pitch *= -1;
}
roll += 180;
yaw += 180;
mCurrentRoll = roll;
mCurrentPitch = pitch;
mCurrentYaw = yaw;
}
开发者ID:Esri,项目名称:arcgis-runtime-demos-android,代码行数:17,代码来源:MyoMapListener.java
示例5: onOrientationData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long timestamp, Quaternion rotation) {
Quaternion normalized = rotation.normalized();
double roll = Math.atan2(2.0f * (normalized.getW() * normalized.getX() + normalized.getY() * normalized.getZ()),
1.0f - 2.0f * (normalized.getX() * normalized.getX() + normalized.getY() * normalized.getY()));
double pitch = Math.asin(2.0f * (normalized.getW() * normalized.getY() - normalized.getZ() * normalized.getX()));
double yaw = Math.atan2(2.0f * (normalized.getW() * normalized.getZ() + normalized.getX() * normalized.getY()),
1.0f - 2.0f * (normalized.getY() * normalized.getY() + normalized.getZ() * normalized.getZ()));
rollW = ((roll + Math.PI) / (Math.PI * 2.0) * SCALE);
pitchW = ((pitch + Math.PI / 2.0) / Math.PI * SCALE);
yawW = ((yaw + Math.PI) / (Math.PI * 2.0) * SCALE);
}
开发者ID:glaudiston,项目名称:project-bianca,代码行数:16,代码来源:MyoThalmic.java
示例6: onOrientationData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long timestamp, Quaternion rotation) {
Quaternion normalized = rotation.normalized();
double roll = Math.atan2(2.0f * (normalized.getW() * normalized.getX() + normalized.getY() * normalized.getZ()), 1.0f - 2.0f * (normalized.getX() * normalized.getX() + normalized.getY() * normalized.getY()));
double pitch = Math.asin(2.0f * (normalized.getW() * normalized.getY() - normalized.getZ() * normalized.getX()));
double yaw = Math.atan2(2.0f * (normalized.getW() * normalized.getZ() + normalized.getX() * normalized.getY()), 1.0f - 2.0f * (normalized.getY() * normalized.getY() + normalized.getZ() * normalized.getZ()));
rollW = ((roll + Math.PI) / (Math.PI * 2.0) * SCALE);
pitchW = ((pitch + Math.PI / 2.0) / Math.PI * SCALE);
yawW = ((yaw + Math.PI) / (Math.PI * 2.0) * SCALE);
}
开发者ID:glaudiston,项目名称:project-bianca,代码行数:13,代码来源:DataCollector.java
示例7: processData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void processData(Myo myo, long timestamp, Quaternion quaternion, DataType type) {
//ADD SUPER THING HERE
if (myo.getXDirection().equals(XDirection.TOWARD_ELBOW))
direction = -1;
if(type.equals(DataType.ORIENTATION)) {
float pitch = (float) Math.toDegrees(Quaternion.pitch(quaternion));
float roll = (float) Math.toDegrees(Quaternion.roll(quaternion));
float yaw = (float) Math.toDegrees(Quaternion.yaw(quaternion));
//Log.i("BicepCurl", "pitch: "+pitch);
//Log.i("BicepCurl", "roll: "+roll);
//Log.i("BicepCurl", "yaw: "+yaw);
if(started) {
if(down && pitch > minAngle) {
down = false;
rep++;
if (!form)
form = true;
// TODO: MAKE OPTION
// myo.vibrate(VibrationType.SHORT);
} else if (!down && pitch < downAngle) {
down = true;
}
}
}
}
开发者ID:myofit,项目名称:MyoFit,代码行数:32,代码来源:TricepKickback.java
示例8: processData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void processData(Myo myo, long timestamp, Quaternion quaternion, DataType type) {
super.processData(myo, timestamp, quaternion, type);
if (myo.getXDirection().equals(XDirection.TOWARD_ELBOW))
direction = -1;
if(type.equals(DataType.ORIENTATION)) {
float pitch = (float) Math.toDegrees(Quaternion.pitch(quaternion));
float roll = (float) Math.toDegrees(Quaternion.roll(quaternion));
float yaw = (float) Math.toDegrees(Quaternion.yaw(quaternion));
//Log.i("BicepCurl", "pitch: "+pitch);
Log.i("BicepCurl", "roll: "+roll);
//Log.i("BicepCurl", "yaw: "+yaw);
if(started) {
if(down && pitch > minAngle) {
down = false;
rep++;
if (!form)
form = true;
// TODO: MAKE OPTION
// myo.vibrate(VibrationType.SHORT);
} else if (!down && pitch < downAngle) {
down = true;
}
}
if(started) {
if (roll < 10 && roll > 40) {
myo.vibrate(VibrationType.SHORT);
formTimeDiff = timestamp;
form = false;
}
}
}
}
开发者ID:myofit,项目名称:MyoFit,代码行数:40,代码来源:SideLateralRaise.java
示例9: processData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void processData(Myo myo, long timestamp, Quaternion quaternion, DataType type) {
super.processData(myo, timestamp, quaternion, type);
if (myo.getXDirection().equals(XDirection.TOWARD_ELBOW))
direction = -1;
if(type.equals(DataType.ORIENTATION)) {
float pitch = (float) Math.toDegrees(Quaternion.pitch(quaternion));
float roll = (float) Math.toDegrees(Quaternion.roll(quaternion));
float yaw = (float) Math.toDegrees(Quaternion.yaw(quaternion));
//Log.i("BicepCurl", "pitch: "+pitch);
//Log.i("BicepCurl", "roll: "+roll);
//Log.i("BicepCurl", "yaw: "+yaw);
if(started) {
if(down && pitch > minAngle) {
down = false;
rep++;
if (!form) {
badForms++;
form = true;
}
// TODO: MAKE OPTION
// myo.vibrate(VibrationType.SHORT);
} else if (!down && pitch < downAngle) {
down = true;
}
}
}
}
开发者ID:myofit,项目名称:MyoFit,代码行数:35,代码来源:BicepCurl.java
示例10: processData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void processData(Myo myo, long timestamp, Quaternion quaternion, DataType type) {
//ADD SUPER THING HERE
if (myo.getXDirection().equals(XDirection.TOWARD_ELBOW))
direction = -1;
if(type.equals(DataType.ORIENTATION)) {
float pitch = (float) Math.toDegrees(Quaternion.pitch(quaternion));
float roll = (float) Math.toDegrees(Quaternion.roll(quaternion));
float yaw = (float) Math.toDegrees(Quaternion.yaw(quaternion));
//Log.i("BicepCurl", "pitch: "+pitch);
//Log.i("BicepCurl", "roll: "+roll);
//Log.i("BicepCurl", "yaw: "+yaw);
if(started) {
if(down && pitch > minAngle) {
down = false;
rep++;
if (!form)
form = true;
// TODO: MAKE OPTION
// myo.vibrate(VibrationType.SHORT);
} else if (!down && pitch < downAngle) {
down = true;
}
}
}
}
开发者ID:myofit,项目名称:MyoFit,代码行数:32,代码来源:DumbbellFly.java
示例11: onOrientationData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long timestamp, Quaternion rotation) {
Quaternion normalized = rotation.normalized();
double roll = Math.atan2(2.0f * (normalized.getW() * normalized.getX() + normalized.getY() * normalized.getZ()), 1.0f - 2.0f * (normalized.getX() * normalized.getX() + normalized.getY() * normalized.getY()));
double pitch = Math.asin(2.0f * (normalized.getW() * normalized.getY() - normalized.getZ() * normalized.getX()));
double yaw = Math.atan2(2.0f * (normalized.getW() * normalized.getZ() + normalized.getX() * normalized.getY()), 1.0f - 2.0f * (normalized.getY() * normalized.getY() + normalized.getZ() * normalized.getZ()));
rollW = ((roll + Math.PI) / (Math.PI * 2.0) * SCALE);
pitchW = ((pitch + Math.PI / 2.0) / Math.PI * SCALE);
yawW = ((yaw + Math.PI) / (Math.PI * 2.0) * SCALE);
}
开发者ID:NicholasAStuart,项目名称:myo-java,代码行数:13,代码来源:DataCollector.java
示例12: onOrientationData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long timestamp, Quaternion rotation) {
updateValues(rotation);
if(mPanningEnabled) {
//X Factor
normalizeYaw();
double yawDiff = ((mCurrentYaw - mStartingYaw) * -1.0) / DIV;
if(Math.abs(yawDiff) >= THRESHOLD) {
yawDiff = (yawDiff < 0) ? yawDiff*yawDiff*-1.0 : yawDiff*yawDiff;
xFactor = factorBase + yawDiff;
} else {
xFactor = factorBase;
}
//Y Factor
double pitchDiff = ((mCurrentPitch - mStartingPitch) * -1.0) / DIV;
if(Math.abs(pitchDiff) >= THRESHOLD) {
pitchDiff = (pitchDiff < 0) ? pitchDiff*pitchDiff*-1.0 : pitchDiff*pitchDiff;
yFactor = factorBase + pitchDiff;
} else {
yFactor = factorBase;
}
if(mPanTimer == null) {
mPanTimer = new Timer();
mPanTimer.schedule(new PanTimerTask(), 0, 16 /*16ms ensure 60Hz refresh rate*/);
}
}
if(myo.isUnlocked() && mCurrentPose == Pose.FIST) {
normalizeRoll();
double rollDiff = mCurrentRoll - mStartingRoll;
if(Math.abs(rollDiff) >= 5.0) {
double newRoll = mMapView.getRotationAngle() + rollDiff;
mMapView.setRotationAngle(newRoll);
}
}
}
开发者ID:Esri,项目名称:arcgis-runtime-demos-android,代码行数:37,代码来源:MyoMapListener.java
示例13: onOrientationData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long timestamp, Quaternion rotation) {
updateValues(rotation);
if(mPanningEnabled) {
//X Factor
normalizeYaw();
double yawDiff = ((mCurrentYaw - mStartingYaw) * -1.0) / DIV;
if(Math.abs(yawDiff) >= THRESHOLD) {
yawDiff = (yawDiff < 0) ? yawDiff*yawDiff*-1.0 : yawDiff*yawDiff;
xFactor = factorBase + yawDiff;
} else {
xFactor = factorBase;
}
//Y Factor
double pitchDiff = ((mCurrentPitch - mStartingPitch) * -1.0) / DIV;
if(Math.abs(pitchDiff) >= THRESHOLD) {
pitchDiff = (pitchDiff < 0) ? pitchDiff*pitchDiff*-1.0 : pitchDiff*pitchDiff;
yFactor = factorBase + pitchDiff;
} else {
yFactor = factorBase;
}
if(mPanTimer == null) {
mPanTimer = new Timer();
mPanTimer.schedule(new PanTimerTask(), 0, 16 /*16ms ensures 60Hz refresh rate*/);
}
}
if(myo.isUnlocked() && mCurrentPose == Pose.FIST) {
normalizeRoll();
double rollDiff = mCurrentRoll - mStartingRoll;
if(Math.abs(rollDiff) >= 5.0) {
double newRoll = mMapView.getRotationAngle() + rollDiff;
mMapView.setRotationAngle(newRoll);
}
}
}
开发者ID:Esri,项目名称:arcgis-runtime-demos-android,代码行数:37,代码来源:MyoMapControlListener.java
示例14: processData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
public void processData(Myo myo, long timestamp, Quaternion quaternion, DataType type) {
exercises.get(position).processData(myo, timestamp, quaternion, type);
this.update();
}
开发者ID:myofit,项目名称:MyoFit,代码行数:5,代码来源:ExerciseManager.java
示例15: processData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
public void processData(Myo myo, long timestamp, Quaternion quaternion, DataType type) {
this.time = timestamp;
}
开发者ID:myofit,项目名称:MyoFit,代码行数:4,代码来源:Exercise.java
示例16: onOrientationData
import com.thalmic.myo.Quaternion; //导入依赖的package包/类
@Override
public void onOrientationData(Myo myo, long timestamp, Quaternion rotation) {
manager.processData(myo, timestamp, rotation, DataType.ORIENTATION);
}
开发者ID:myofit,项目名称:MyoFit,代码行数:5,代码来源:MyDeviceListener.java
注:本文中的com.thalmic.myo.Quaternion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论