「VCS/Quaternion」の編集履歴(バックアップ)一覧はこちら

VCS/Quaternion - (2012/12/13 (木) 11:55:13) の1つ前との変更点

追加された行は緑色になります。

削除された行は赤色になります。

|開発環境|Microsoft Visual C# 2010 Express (SP1)| |実行環境|Microsoft Windows XP Home Edition (SP3)| |プロジェクトの種類|空のプロジェクト| |プロジェクト名|dirext| Program.cs #highlight(c#){{ using System; using Microsoft.Xna.Framework; // .NET参照 class Program { static void Main() { Quaternion q1, q2; float rad = MathHelper.ToRadians(45); float y = (float)Math.Sin(rad); float r = (float)Math.Cos(rad); Console.WriteLine("lat=0 +xから+zへ"); q1 = new Quaternion(1, 0, 0, 0); q2 = new Quaternion(0, 0, 1, 0); Slerp(q1, q2); Console.WriteLine("lat=45 +xから+zへ"); q1 = new Quaternion(r, y, 0, 0); q2 = new Quaternion(0, y, r, 0); Slerp(q1, q2); Console.WriteLine("lat=45 +xから-xへ"); q1 = new Quaternion(r, y, 0, 0); q2 = new Quaternion(-r, y, 0, 0); Slerp(q1, q2); Console.ReadLine(); } static void Slerp(Quaternion q1, Quaternion q2) { for (int n = 0; n <= 4; n++) { float t = n / 4.0f; Quaternion q = Quaternion.Slerp(q1, q2, t); float lat = MathHelper.ToDegrees((float)Math.Asin(q.Y)); float xz = MathHelper.ToDegrees((float)Math.Atan2(q.Z, q.X)); float xy = MathHelper.ToDegrees((float)Math.Atan2(q.Y, q.X)); Console.WriteLine(String.Format( "t={0:f2} x={1:f2} y={2:f2} z={3:f2} w={4:f2} lat={5:f2} long={6:f2} xy={7:f2}", t, q.X, q.Y, q.Z, q.W, lat, xz, xy)); } } } }} 出力 lat=0 +xから+zへ t=0.00 x=1.00 y=0.00 z=0.00 w=0.00 lat=0.00 long=0.00 xy=0.00 t=0.25 x=0.92 y=0.00 z=0.38 w=0.00 lat=0.00 long=22.50 xy=0.00 t=0.50 x=0.71 y=0.00 z=0.71 w=0.00 lat=0.00 long=45.00 xy=0.00 t=0.75 x=0.38 y=0.00 z=0.92 w=0.00 lat=0.00 long=67.50 xy=0.00 t=1.00 x=0.00 y=0.00 z=1.00 w=0.00 lat=0.00 long=90.00 xy=0.00 lat=45 +xから+zへ t=0.00 x=0.71 y=0.71 z=0.00 w=0.00 lat=45.00 long=0.00 xy=45.00 t=0.25 x=0.58 y=0.79 z=0.21 w=0.00 lat=52.06 long=20.10 xy=53.79 t=0.50 x=0.41 y=0.82 z=0.41 w=0.00 lat=54.74 long=45.00 xy=63.43 t=0.75 x=0.21 y=0.79 z=0.58 w=0.00 lat=52.06 long=69.90 xy=75.00 t=1.00 x=0.00 y=0.71 z=0.71 w=0.00 lat=45.00 long=90.00 xy=90.00 lat=45 +xから-xへ t=0.00 x=0.71 y=0.71 z=0.00 w=0.00 lat=45.00 long=0.00 xy=45.00 t=0.25 x=0.38 y=0.92 z=0.00 w=0.00 lat=67.50 long=0.00 xy=67.50 t=0.50 x=0.00 y=1.00 z=0.00 w=0.00 lat=89.98 long=0.00 xy=90.00 t=0.75 x=-0.38 y=0.92 z=0.00 w=0.00 lat=67.50 long=180.00 xy=112.50 t=1.00 x=-0.71 y=0.71 z=0.00 w=0.00 lat=45.00 long=180.00 xy=135.00
|開発環境|Microsoft Visual C# 2010 Express (SP1)| |実行環境|Microsoft Windows XP Home Edition (SP3)| |プロジェクトの種類|空のプロジェクト| |プロジェクト名|Quaternion| Program.cs #highlight(c#){{ using System; using Microsoft.Xna.Framework; // .NET参照 class Program { static void Main() { Quaternion q1, q2; float rad = MathHelper.ToRadians(45); float y = (float)Math.Sin(rad); float r = (float)Math.Cos(rad); Console.WriteLine("lat=0 +xから+zへ"); q1 = new Quaternion(1, 0, 0, 0); q2 = new Quaternion(0, 0, 1, 0); Slerp(q1, q2); Console.WriteLine("lat=45 +xから+zへ"); q1 = new Quaternion(r, y, 0, 0); q2 = new Quaternion(0, y, r, 0); Slerp(q1, q2); Console.WriteLine("lat=45 +xから-xへ"); q1 = new Quaternion(r, y, 0, 0); q2 = new Quaternion(-r, y, 0, 0); Slerp(q1, q2); Console.ReadLine(); } static void Slerp(Quaternion q1, Quaternion q2) { for (int n = 0; n <= 4; n++) { float t = n / 4.0f; Quaternion q = Quaternion.Slerp(q1, q2, t); float lat = MathHelper.ToDegrees((float)Math.Asin(q.Y)); float xz = MathHelper.ToDegrees((float)Math.Atan2(q.Z, q.X)); float xy = MathHelper.ToDegrees((float)Math.Atan2(q.Y, q.X)); Console.WriteLine(String.Format( "t={0:f2} x={1:f2} y={2:f2} z={3:f2} w={4:f2} lat={5:f2} long={6:f2} xy={7:f2}", t, q.X, q.Y, q.Z, q.W, lat, xz, xy)); } } } }} 出力 lat=0 +xから+zへ t=0.00 x=1.00 y=0.00 z=0.00 w=0.00 lat=0.00 long=0.00 xy=0.00 t=0.25 x=0.92 y=0.00 z=0.38 w=0.00 lat=0.00 long=22.50 xy=0.00 t=0.50 x=0.71 y=0.00 z=0.71 w=0.00 lat=0.00 long=45.00 xy=0.00 t=0.75 x=0.38 y=0.00 z=0.92 w=0.00 lat=0.00 long=67.50 xy=0.00 t=1.00 x=0.00 y=0.00 z=1.00 w=0.00 lat=0.00 long=90.00 xy=0.00 lat=45 +xから+zへ t=0.00 x=0.71 y=0.71 z=0.00 w=0.00 lat=45.00 long=0.00 xy=45.00 t=0.25 x=0.58 y=0.79 z=0.21 w=0.00 lat=52.06 long=20.10 xy=53.79 t=0.50 x=0.41 y=0.82 z=0.41 w=0.00 lat=54.74 long=45.00 xy=63.43 t=0.75 x=0.21 y=0.79 z=0.58 w=0.00 lat=52.06 long=69.90 xy=75.00 t=1.00 x=0.00 y=0.71 z=0.71 w=0.00 lat=45.00 long=90.00 xy=90.00 lat=45 +xから-xへ t=0.00 x=0.71 y=0.71 z=0.00 w=0.00 lat=45.00 long=0.00 xy=45.00 t=0.25 x=0.38 y=0.92 z=0.00 w=0.00 lat=67.50 long=0.00 xy=67.50 t=0.50 x=0.00 y=1.00 z=0.00 w=0.00 lat=89.98 long=0.00 xy=90.00 t=0.75 x=-0.38 y=0.92 z=0.00 w=0.00 lat=67.50 long=180.00 xy=112.50 t=1.00 x=-0.71 y=0.71 z=0.00 w=0.00 lat=45.00 long=180.00 xy=135.00

表示オプション

横に並べて表示:
変化行の前後のみ表示: