• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Quaternion类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HTTPSampleResult类代码示例发布时间:2022-05-23
下一篇:
Java TestUtilities类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap