我正在尝试在WPF项目中旋转对象。我有一个问题,例如是否有Unity中的函数:<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<form action="" method="GET">
<div class="row">
<div class="col-lg-6 col-xs-6 col-md-4 col-lg-offset-3" id="searchForm">
<p class="header">Search movie by title</p>
<div class="input-group">
<input type="text" class="form-control api-key" placeholder="API Key" />
<input type="text" class="form-control" placeholder="Enter movie name" id="txtSearch" />
<div class="input-group-btn">
<button class="btn btn-primary" type="submit" id="formSubmit">
<span class="glyphicon glyphicon-search"></span>
</button>
</div>
</div>
</div>
</div>
</form>
<div class="row results">
<div class="col-md-12 result hidden">
<h3 class="title"></h3>
<img class="img" src="" />
</div>
</div>
您需要做的就是将计算出的四元数放入函数中。我使用以下公式计算了旋转四元数:formula picture,并且在我的代码中看起来像这样:
shape.transform.rotation = q.ToUnityQuaternion();
乘法函数如下:
Quat qx = new Quat(Mathf.Cos(inputX / 2), 0, 0, Mathf.Sin(inputX / 2));
//0,1,0
Quat qy = new Quat(Mathf.Cos(inputY / 2), 0, Mathf.Sin(inputY / 2), 0);
//1,0,0
Quat qz = new Quat(Mathf.Cos(inputZ / 2), Mathf.Sin(inputZ / 2), 0, 0);
q = Multiply(qx, q);
q = Multiply(qy, q);
q = Multiply(qz, q);