本文整理汇总了C#中Quaternion.GetRotation方法的典型用法代码示例。如果您正苦于以下问题:C# Quaternion.GetRotation方法的具体用法?C# Quaternion.GetRotation怎么用?C# Quaternion.GetRotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quaternion
的用法示例。
在下文中一共展示了Quaternion.GetRotation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QuaternionToPlane
public static Plane QuaternionToPlane(Point3d point, Quaternion quaternion)
{
Plane plane;
quaternion.GetRotation(out plane);
plane.Origin = point;
return plane;
}
示例2: RunCommand
protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
{
pluginObj = ((nishanchiPlugin)this.PlugIn);
RhinoView viewObj = doc.Views.ActiveView;
RhinoViewport viewPortObj = viewObj.ActiveViewport;
Vector3d originalCameraVector = viewPortObj.CameraDirection;
Point3d originalCameraLocation = viewPortObj.CameraLocation;
Mesh meshObj;
Boolean logging = false;
StreamWriter logWriter = null;
String reportString;
String logString;
String printCommandStr;
if (((nishanchiPlugin)this.PlugIn).logEnabled())
{
logWriter = new StreamWriter(((nishanchiPlugin)this.PlugIn).getNewLogFile());
logWriter.WriteLine("Printing...");
logging = true;
}
if (!pluginObj.trackerConnected)
{
RhinoApp.WriteLine("Tracker disconnected");
return Rhino.Commands.Result.Failure;
}
connectKbEvt();
Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject();
go.SetCommandPrompt("Select the mesh to print");
go.Get();
Result rc = go.CommandResult();
if (rc != Rhino.Commands.Result.Success)
{
disconnectKbEvt();
return rc;
}
meshObj = new Mesh();
if (go.ObjectCount == 1){
ObjRef tmpRef = new ObjRef(go.Object(0).ObjectId);
meshObj = tmpRef.Mesh();
if (meshObj == null){
disconnectKbEvt();
return rc;
}
}
createNozzles(doc);
cameraPoint = new tPoint(Nozzle.XOffset + 100.0, Nozzle.YOffset, Nozzle.ZOffset + (Nozzle.ZMultiplier * ((numNozzles-1)/2)));
fastrak trackerObj = pluginObj.trackerObj;
int numPoints = 0;
Boolean retval;
RhinoApp.WriteLine(string.Format("Starting continuous mode on the tracker."));
pluginObj.trackerObj.setContinuous();
RhinoApp.WriteLine(string.Format("Printing mode enabled now."));
running = true;
while (running)
{
retval = trackerObj.readFrame();
if (retval)
{
//q0,q1,q2,q3 Quaternion begin
//Compute the rotation matrix
reportString = String.Format("{0},{1},{2}", trackerObj.x, trackerObj.y, trackerObj.z);
logString = String.Format("p,{0},{1},{2},{3},{4},{5},{6},{7}", numPoints, trackerObj.x, trackerObj.y, trackerObj.z, trackerObj.q0, trackerObj.q1, trackerObj.q2, trackerObj.q3);
RhinoApp.WriteLine(reportString);
if (logging)
{
logWriter.WriteLine(logString);
}
rxTxTx = new Point3d(trackerObj.x, trackerObj.y, trackerObj.z);
orientationQuat = new Quaternion(trackerObj.q0, trackerObj.q1, trackerObj.q2, trackerObj.q3);
orientationQuat.GetRotation(out angle, out axis);
rotMat = Transform.Rotation(angle, axis, origin);
// Compute the new positions for the nozzlePoints and also compute the new lines
for (int i = 0; i < numNozzles; i++)
{
nozzles[i].computeTxTx(rotMat, rxTxTx);
}
//And, I move the view around
if ((numPoints % 100) == 0)
{
cameraPoint.computeTxTx(rotMat, rxTxTx);
viewPortObj.SetCameraLocation(cameraPoint.txTx(), true);
viewPortObj.SetCameraDirection(nozzles[4].vector(), true);
viewPortObj.Rotate(Math.PI / 2, nozzles[4].vector(), cameraPoint.txTx());
cameraUpTx = rotMat * cameraUpRx;
//.........这里部分代码省略.........
示例3: RunCommand
protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
{
nishanchiPlugin pluginObj = ((nishanchiPlugin)this.PlugIn);
Boolean retval;
Boolean logging = false;
StreamWriter logWriter = null;
String reportString;
String logString;
if (pluginObj.trackerConnected)
{
fastrak trackerObj = pluginObj.trackerObj;
int numPoints = 0;
RhinoApp.WriteLine(string.Format("Digitizing mode enabled"));
pluginObj.trackerObj.setContinuous();
running = true;
connectKbEvt();
float x0, y0, z0;
if (((nishanchiPlugin)this.PlugIn).logEnabled())
{
logWriter = new StreamWriter(((nishanchiPlugin)this.PlugIn).getNewLogFile());
logWriter.WriteLine("Digitizing...");
logging = true;
}
while (running)
{
retval = trackerObj.readFrame();
if (retval)
{
reportString = String.Format("{0},{1},{2}", trackerObj.x, trackerObj.y, trackerObj.z);
logString = String.Format("{0},{1},{2},{3},{4},{5},{6},{7}",numPoints,trackerObj.x, trackerObj.y, trackerObj.z, trackerObj.q0, trackerObj.q1, trackerObj.q2, trackerObj.q3);
RhinoApp.WriteLine(reportString);
if (logging){
logWriter.WriteLine(logString);
}
x0 = trackerObj.x;
y0 = trackerObj.y;
z0 = trackerObj.z;
// x,y,z translation end
//q0,q1,q2,q3 Quaternion begin
rxTxTx = new Point3d(x0, y0, z0);
orientationQuat = new Quaternion(trackerObj.q0, trackerObj.q1, trackerObj.q2, trackerObj.q3);
orientationQuat.GetRotation(out angle, out axis);
rotTransform = Transform.Rotation(angle, axis, origin);
tipRxTx = rotTransform * tipRxRx;
//Vector3d rTipRxTxV = orientationQuat.Rotate(tipRxRxV);
tipTxTx = tipRxTx + rxTxTx;
doc.Objects.AddPoint(tipTxTx);
numPoints++;
if ((numPoints % 10) == 0)
{
//RhinoApp.WriteLine(String.Format("Tracker: {0},{1},{2}", trackerObj.x, trackerObj.y, trackerObj.z));
//RhinoApp.WriteLine(String.Format("Point: {0},{1},{2}", tipTxTx.X, tipTxTx.Y, tipTxTx.Z));
doc.Views.ActiveView.Redraw();
RhinoApp.Wait();
}
}
else
{
RhinoApp.WriteLine("Tracker refused to give a frame.");
}
}
if (logging)
{
logWriter.Close();
((nishanchiPlugin)this.PlugIn).closeLogFile();
}
disconnectKbEvt();
}
else
{
RhinoApp.WriteLine("Tracker disconnected");
}
RhinoApp.WriteLine(string.Format("I guess you don't wanna digitize anymore, well who cares! Not me!"));
return Rhino.Commands.Result.Success;
}
示例4: RunCommand
protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
{
nishanchiPlugin pluginObj = ((nishanchiPlugin)this.PlugIn);
Boolean selectedObjectIsBrep = false;
Boolean selectedObjectIsCurve = false;
if (!pluginObj.trackerConnected)
{
RhinoApp.WriteLine("Tracker disconnected");
return Rhino.Commands.Result.Failure;
}
connectKbEvt();
//Ask the user to select Breps to print.
//Result rc = Rhino.Input.RhinoGet.GetMultipleObjects("Select the surfaces to print",
//false, Rhino.DocObjects.ObjectType.Surface, out objrefs);
Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject();
go.SetCommandPrompt("Select the entity to print");
go.GroupSelect = true;
//Set this to go.GetMultiple(0,0) if you want to allow multiple entities to be selected
go.GetMultiple(0, 1);
Result rc = go.CommandResult();
if (rc != Rhino.Commands.Result.Success)
{
disconnectKbEvt();
return rc;
}
List<Rhino.Geometry.Brep> breps = new List<Rhino.Geometry.Brep>();
List<Rhino.Geometry.Curve> curves = new List<Rhino.Geometry.Curve>();
for (int i = 0; i < go.ObjectCount; i++)
{
ObjRef tmpRef = new ObjRef(go.Object(i).ObjectId);
Rhino.Geometry.Brep brep = tmpRef.Brep();
if (brep != null)
{
breps.Add(brep);
selectedObjectIsBrep = true;
}
Rhino.Geometry.Curve curve = tmpRef.Curve();
if (curve != null)
{
curves.Add(curve);
selectedObjectIsCurve = true;
}
}
if (selectedObjectIsBrep)
RhinoApp.WriteLine("Selected " + breps.Count + " surfaces! Good! No, not, really, I'm just a program, I couldn't care less.");
if (selectedObjectIsCurve)
RhinoApp.WriteLine("Selected " + curves.Count + " curves! Good! No, not, really, I'm just a program, I couldn't care less.");
createEntities(doc);
fastrak trackerObj = pluginObj.trackerObj;
int numPoints = 0;
int numIntersections = 0;
Boolean retval;
RhinoApp.WriteLine(string.Format("Starting continuous mode on the tracker."));
pluginObj.trackerObj.setContinuous();
RhinoApp.WriteLine(string.Format("Printing mode enabled now."));
Curve[] intersectionCurves;
Point3d[] intersectionPoints;
running = true;
while (running)
{
retval = trackerObj.readFrame();
if (retval)
{
//q0,q1,q2,q3 Quaternion begin
//Compute the rotation matrix
rxTxTx = new Point3d(trackerObj.x, trackerObj.y, trackerObj.z);
orientationQuat = new Quaternion(trackerObj.q0, trackerObj.q1, trackerObj.q2, trackerObj.q3);
orientationQuat.GetRotation(out angle, out axis);
rotMat = Transform.Rotation(angle, axis, origin);
// Compute the new positions for the nozzlePoints and also compute the new lines
for (int i = 0; i < numNozzles; i++)
{
nozzleStartPointRxTx[i] = rotMat * nozzleStartPointRxRx[i];
nozzleStartPointTxTx[i] = nozzleStartPointRxTx[i] + rxTxTx;
nozzleEndPointRxTx[i] = rotMat * nozzleEndPointRxRx[i];
nozzleEndPointTxTx[i] = nozzleEndPointRxTx[i] + rxTxTx;
nozzleLinesTx[i] = new Line(nozzleStartPointTxTx[i], nozzleEndPointTxTx[i]);
nozzleCurves[i] = new LineCurve(nozzleLinesTx[i]);
}
//.........这里部分代码省略.........