protected override async Task LoadContent() { await base.LoadContent(); wireframeState = new RasterizerStateDescription(CullMode.Back) { FillMode = FillMode.Wireframe }; simpleEffect = new EffectInstance(new Effect(GraphicsDevice, SpriteEffect.Bytecode)); // TODO GRAPHICS REFACTOR simpleEffect.Parameters.Set(TexturingKeys.Texture0, UVTexture); simpleEffect.UpdateEffect(GraphicsDevice); primitives = new List<GeometricPrimitive>(); // Creates all primitives primitives = new List<GeometricPrimitive> { GeometricPrimitive.Plane.New(GraphicsDevice), GeometricPrimitive.Cube.New(GraphicsDevice), GeometricPrimitive.Sphere.New(GraphicsDevice), GeometricPrimitive.GeoSphere.New(GraphicsDevice), GeometricPrimitive.Cylinder.New(GraphicsDevice), GeometricPrimitive.Torus.New(GraphicsDevice), GeometricPrimitive.Teapot.New(GraphicsDevice), GeometricPrimitive.Capsule.New(GraphicsDevice, 0.5f, 0.3f), GeometricPrimitive.Cone.New(GraphicsDevice) }; view = Matrix.LookAtRH(new Vector3(0, 0, 5), new Vector3(0, 0, 0), Vector3.UnitY); Window.AllowUserResizing = true; }
public void FromMatrix(ref Matrix matrix) { Position = matrix.Translation; Quaternion q; Quaternion.CreateFromRotationMatrix(ref matrix, out q); Orientation = new HalfVector4(q.ToVector4()); }
/// <summary> /// For each input vector (which are rows of the matrix <paramref name="samples"/>) the method finds k <= get_max_k() nearest neighbor. In case of regression, the predicted result will be a mean value of the particular vector's neighbor responses. In case of classification the class is determined by voting. /// </summary> /// <param name="samples">The sample matrix where each row is a sample</param> /// <param name="k">The number of nearest neighbor to find</param> /// <param name="results"> /// Can be null if not needed. /// If regression, return a mean value of the particular vector's neighbor responses; /// If classification, return the class determined by voting. /// </param> /// <param name="kNearestNeighbors">Should be null if not needed. Setting it to non-null values incures a performance panalty. A matrix of (k * samples.Rows) rows and (samples.Cols) columns that will be filled the data of the K nearest-neighbor for each sample</param> /// <param name="neighborResponses">Should be null if not needed. The response of the neighbors. A vector of k*_samples->rows elements.</param> /// <param name="dist">Should be null if not needed. The distances from the input vectors to the neighbors. A vector of k*_samples->rows elements.</param> /// <returns>In case of regression, the predicted result will be a mean value of the particular vector's neighbor responses. In case of classification the class is determined by voting</returns> public float FindNearest( Matrix<float> samples, int k, Matrix<float> results, Matrix<float> kNearestNeighbors, Matrix<float> neighborResponses, Matrix<float> dist) { IntPtr[] neighbors = null; if (kNearestNeighbors != null) { Debug.Assert(kNearestNeighbors.Rows == k * samples.Rows && kNearestNeighbors.Cols == samples.Cols, "The kNeighbors must have (k*samples.Rows) rows and samples.Cols columns."); neighbors = new IntPtr[k * samples.Rows]; } float res = MlInvoke.CvKNearestFindNearest(_ptr, samples.Ptr, k, results, neighbors, neighborResponses, dist); if (kNearestNeighbors != null) { IntPtr data; int step; Size size; CvInvoke.cvGetRawData(kNearestNeighbors.Ptr, out data, out step, out size); Int64 dataAddress = data.ToInt64(); int elements = k * samples.Rows; int length = samples.Cols * sizeof(float); for (int i = 0; i < elements; i++) { Emgu.Util.Toolbox.memcpy(new IntPtr(dataAddress + i * step), neighbors[i], length); } } return res; }
public static void InverseDeterminant(Matrix matrix, out Matrix inverse, out double determinant) { int n = matrix.Rows; if (matrix.Columns != n) { throw new ArgumentException("The matrix isn't a square matrix."); } double[,] a = matrix.ToArray(); if (!trfac.spdmatrixcholesky(ref a, n, false)) { throw new ArithmeticException(); } determinant = matdet.spdmatrixcholeskydet(ref a, n); int info = 0; matinv.matinvreport rep = new matinv.matinvreport(); matinv.spdmatrixcholeskyinverse(ref a, n, false, ref info, ref rep); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { a[i, j] = a[j, i]; } } inverse = new Matrix(a); }
/// <summary> /// Initializes a new instance of the <see cref="UserQR"/> class. This object will compute the /// QR factorization when the constructor is called and cache it's factorization. /// </summary> /// <param name="matrix">The matrix to factor.</param> /// <exception cref="ArgumentNullException">If <paramref name="matrix"/> is <c>null</c>.</exception> public UserQR(Matrix matrix) { if (matrix == null) { throw new ArgumentNullException("matrix"); } if (matrix.RowCount < matrix.ColumnCount) { throw new ArgumentException(Resources.ArgumentMatrixDimensions); } MatrixR = matrix.Clone(); MatrixQ = matrix.CreateMatrix(matrix.RowCount, matrix.RowCount); for (var i = 0; i < matrix.RowCount; i++) { MatrixQ.At(i, i, 1.0); } var minmn = Math.Min(matrix.RowCount, matrix.ColumnCount); var u = new double[minmn][]; for (var i = 0; i < minmn; i++) { u[i] = GenerateColumn(MatrixR, i, matrix.RowCount - 1, i); ComputeQR(u[i], MatrixR, i, matrix.RowCount - 1, i + 1, matrix.ColumnCount - 1); } for (var i = minmn - 1; i >= 0; i--) { ComputeQR(u[i], MatrixQ, i, matrix.RowCount - 1, i, matrix.RowCount - 1); } }
public void TestInit() { var matrix = new Matrix<int>(5, 5); int[] row = { 2, 2, 2, 2, 2 }; matrix.Init(2); Assert.AreEqual(row, matrix.GetRow(2)); }
public void Matrix_Conversion_ToXna() { var matrix = new Matrix( 11, 12, 13, 14, 21, 22, 23, 24, 31, 32, 33, 34, 41, 42, 43, 44); XnaMatrix xnaMatrix = matrix.ToXna(); Assert.AreEqual(matrix.R1C1, xnaMatrix.M11); Assert.AreEqual(matrix.R1C2, xnaMatrix.M12); Assert.AreEqual(matrix.R1C3, xnaMatrix.M13); Assert.AreEqual(matrix.R1C4, xnaMatrix.M14); Assert.AreEqual(matrix.R2C1, xnaMatrix.M21); Assert.AreEqual(matrix.R2C2, xnaMatrix.M22); Assert.AreEqual(matrix.R2C3, xnaMatrix.M23); Assert.AreEqual(matrix.R2C4, xnaMatrix.M24); Assert.AreEqual(matrix.R3C1, xnaMatrix.M31); Assert.AreEqual(matrix.R3C2, xnaMatrix.M32); Assert.AreEqual(matrix.R3C3, xnaMatrix.M33); Assert.AreEqual(matrix.R3C4, xnaMatrix.M34); Assert.AreEqual(matrix.R4C1, xnaMatrix.M41); Assert.AreEqual(matrix.R4C2, xnaMatrix.M42); Assert.AreEqual(matrix.R4C3, xnaMatrix.M43); Assert.AreEqual(matrix.R4C4, xnaMatrix.M44); }
/// <summary> /// Cholesky algorithm for symmetric and positive definite matrix. /// </summary> /// <param name="matrix">Square, symmetric matrix.</param> public CholeskyDecomposition(Matrix matrix) { // Initialize. double[][] a = matrix.Data; n = matrix.Rows; l = EngineArray.AllocateDouble2D(n, n); isspd = (matrix.Cols == n); // Main loop. for (int j = 0; j < n; j++) { double[] lrowj = l[j]; double d = 0.0; for (int k = 0; k < j; k++) { double[] lrowk = l[k]; double s = 0.0; for (int i = 0; i < k; i++) { s += lrowk[i] * lrowj[i]; } s = (a[j][k] - s) / l[k][k]; lrowj[k] = s; d = d + s * s; isspd = isspd & (a[k][j] == a[j][k]); } d = a[j][j] - d; isspd = isspd & (d > 0.0); l[j][j] = Math.Sqrt(Math.Max(d, 0.0)); for (int k = j + 1; k < n; k++) { l[j][k] = 0.0; } } }
public static void Test2() { const uint MARGIN = 1; Matrix mA = new Matrix(2 + MARGIN, 3 + MARGIN); Matrix mB = new Matrix(3, 2); Matrix mC = new Matrix(2, 2); mA.SetValue(0 + MARGIN, 0 + MARGIN, 0.11); mA.SetValue(0 + MARGIN, 1 + MARGIN, 0.12); mA.SetValue(0 + MARGIN, 2 + MARGIN, 0.13); mA.SetValue(1 + MARGIN, 0 + MARGIN, 0.21); mA.SetValue(1 + MARGIN, 1 + MARGIN, 0.22); mA.SetValue(1 + MARGIN, 2 + MARGIN, 0.23); mB.SetValue(0, 0, 1011); mB.SetValue(0, 1, 1012); mB.SetValue(1, 0, 1021); mB.SetValue(1, 1, 1022); mB.SetValue(2, 0, 1031); mB.SetValue(2, 1, 1032); MatrixView mViewA = new MatrixView(mA, MARGIN, MARGIN, mA.Columns - MARGIN, mA.Rows - MARGIN); MatrixView mViewB = new MatrixView(mB, 0, 0, mB.Columns, mB.Rows); MatrixView mViewC = new MatrixView(mC, 0, 0, mC.Columns, mC.Rows); Blas.DGemm(Blas.TransposeType.NoTranspose, Blas.TransposeType.NoTranspose, 1.0, mViewA, mViewB, 0.0, ref mViewC); Console.WriteLine(mC.GetValue(0, 0) + " , " + mC.GetValue(0, 1)); Console.WriteLine(mC.GetValue(1, 0) + " , " + mC.GetValue(1, 1)); }
public static void Test() { Matrix mA = new Matrix(2, 3); Matrix mB = new Matrix(3, 2); Matrix mC = new Matrix(2, 2); mA.SetValue(0, 0, 0.11); mA.SetValue(0, 1, 0.12); mA.SetValue(0, 2, 0.13); mA.SetValue(1, 0, 0.21); mA.SetValue(1, 1, 0.22); mA.SetValue(1, 2, 0.23); mB.SetValue(0, 0, 1011); mB.SetValue(0, 1, 1012); mB.SetValue(1, 0, 1021); mB.SetValue(1, 1, 1022); mB.SetValue(2, 0, 1031); mB.SetValue(2, 1, 1032); Blas.DGemm(Blas.TransposeType.NoTranspose, Blas.TransposeType.NoTranspose, 1.0, mA, mB, 0.0, ref mC); Console.WriteLine(mC.GetValue(0, 0) + " , " + mC.GetValue(0, 1)); Console.WriteLine(mC.GetValue(1, 0) + " , " + mC.GetValue(1, 1)); }
/// <summary> /// Given an input feature, a feature space and its associated labels, and a positive integer 'k', /// Determines the 'k' nearest neighbor label for the input feature. The 'k' value corresponds /// to the number of nearest neighbors to use in the voting process. /// /// <remarks> /// "When I have this grid of data points, and I provide one additional example row, find the 'k' number /// of rows that are most similar, count up the number of occurrences of each label for each row (1 to 'k'), /// and choose the label with the highest occurrence." /// </remarks> /// <see href="http://en.wikipedia.org/wiki/K-nearest_neighbor_algorithm" /> /// </summary> /// <param name="distanceType">The type of equation to use when measuring the distance between each data point</param> /// <param name="input">The matrix row to input; must have the same number of columns as the feature space</param> /// <param name="featureSpace">The feature space matrix; everything we know</param> /// <param name="labels">The results for each feature space row; what we call each collection of data points</param> /// <param name="k">The number of nearest neighbors to include in the voting; the label with the most occurrences in 'k' neighbors wins</param> /// <returns></returns> public static string Classify(DistanceType distanceType, Number[] input, Matrix featureSpace, IList<string> labels, int k) { if (labels.Count() != featureSpace.Rows) { throw new ArgumentException("The number of labels must match the number of rows of data in the feature space", "labels"); } var distances = CalculateDistances(distanceType, featureSpace, input); var nearestNeighbors = distances.OrderByDescending(d => d.Value).Take(k); var votes = new Dictionary<string, int>(k); foreach (var label in nearestNeighbors.Select(neighbor => labels[neighbor.Key])) { if (votes.ContainsKey(label)) { votes[label]++; } else { votes.Add(label, 1); } } var nearest = votes.OrderByDescending(v => v.Value).First().Key; return nearest; }
public void AddChildShape(ref Matrix localTransform, CollisionShape shape) { m_updateRevision++; //m_childTransforms.push_back(localTransform); //m_childShapes.push_back(shape); CompoundShapeChild child = new CompoundShapeChild(); child.m_transform = localTransform; child.m_childShape = shape; child.m_childShapeType = shape.ShapeType; child.m_childMargin = shape.Margin; //extend the local aabbMin/aabbMax Vector3 localAabbMin = new Vector3(); Vector3 localAabbMax = new Vector3(); shape.GetAabb(ref localTransform, ref localAabbMin, ref localAabbMax); MathUtil.VectorMin(ref localAabbMin, ref m_localAabbMin); MathUtil.VectorMax(ref localAabbMax, ref m_localAabbMax); if (m_dynamicAabbTree != null) { DbvtAabbMm bounds = DbvtAabbMm.FromMM(ref localAabbMin, ref localAabbMax); int index = m_children.Count; child.m_treeNode = m_dynamicAabbTree.Insert(ref bounds, (Object)index); } m_children.Add(child); }
public HingeConstraint(RigidBody rigidBodyA, Matrix rigidBodyAFrame, bool useReferenceFrameA = false) : base(btHingeConstraint_new8(rigidBodyA._native, ref rigidBodyAFrame, useReferenceFrameA)) { _rigidBodyA = rigidBodyA; _rigidBodyB = GetFixedBody(); }
/// <summary> /// /// </summary> void ComputeEnvLightsTiles ( Matrix view, Matrix proj, LightSet lightSet ) { var vp = Game.GraphicsDevice.DisplayBounds; envLightData = Enumerable .Range(0,RenderSystem.MaxEnvLights) .Select( i => new EnvLightGPU(){ Position = Vector4.Zero, Intensity = Vector4.Zero }) .ToArray(); int index = 0; foreach ( var light in lightSet.EnvLights ) { Vector4 min, max; var visible = GetSphereExtent( view, proj, light.Position, vp, light.RadiusOuter, out min, out max ); /*if (!visible) { continue; } */ envLightData[index].Position = new Vector4( light.Position, light.RadiusOuter ); envLightData[index].Intensity = new Vector4( light.Intensity.ToVector3(), 1.0f / light.RadiusOuter / light.RadiusOuter ); envLightData[index].ExtentMax = max; envLightData[index].ExtentMin = min; envLightData[index].InnerOuterRadius= new Vector4( light.RadiusInner, light.RadiusOuter, 0, 0 ); index++; } envLightBuffer.SetData( envLightData ); }
static void Main() { var myMatrix = new Matrix<double>(3, 3); helper.PrintColorText("Filling Matrix:\n\n", "cyan"); for (int i = 0; i < myMatrix.Rows; i++) { for (int j = 0; j < myMatrix.Cols; j++) { myMatrix[i, j] = (i + 1) * (j + 1); helper.PrintColorText(myMatrix[i, j].ToString() + "\n", "green"); } } Console.WriteLine(); IIterator iterator = myMatrix.GetIterator(); helper.PrintColorText("Iterationg Matrix in reverse:\n\n", "cyan"); while (!iterator.IsDone()) { helper.PrintColorText(iterator.CurrentItem().ToString() + "\n", "green"); iterator.Next(); } Console.WriteLine(); }
protected override void Classify() { for (int i = 0; i < FinalFeatures.Count(); i++) { if (Double.IsNaN(FinalFeatures[i])) FinalFeatures[i] = 0; } Matrix x = new Matrix(11, 1); int j=0; foreach(int i in indices) x[i, 0] = FinalFeatures[j++]; List<double> prob = new List<double>(); for (int i = 0; i < 5; i++) { double aa = GaussDistrib.Probability(x, mus[i], sigmas[i]); prob.Add(weight[i] * aa); } EmoClassifierResult res = new EmoClassifierResult(); res.Anger = prob[0]; res.Sadness = prob[1]; res.Neutral = prob[2]; res.Joy = prob[3]; res.Fear = prob[4]; ClassifierEventArgs e = new ClassifierEventArgs(); e.Result = res; ClassificationComplete.Invoke(this, e); }
protected override async Task LoadContent() { await base.LoadContent(); var view = Matrix.LookAtRH(new Vector3(2,2,2), new Vector3(0, 0, 0), Vector3.UnitY); var projection = Matrix.PerspectiveFovRH((float)Math.PI / 4.0f, (float)GraphicsDevice.BackBuffer.ViewWidth / GraphicsDevice.BackBuffer.ViewHeight, 0.1f, 100.0f); worldViewProjection = Matrix.Multiply(view, projection); geometry = GeometricPrimitive.Cube.New(GraphicsDevice); simpleEffect = new Effect(GraphicsDevice, SpriteEffect.Bytecode); parameterCollection = new ParameterCollection(); parameterCollectionGroup = new EffectParameterCollectionGroup(GraphicsDevice, simpleEffect, new[] { parameterCollection }); parameterCollection.Set(TexturingKeys.Texture0, UVTexture); // TODO DisposeBy is not working with device reset offlineTarget0 = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget).DisposeBy(this); offlineTarget1 = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget).DisposeBy(this); offlineTarget2 = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget).DisposeBy(this); depthBuffer = Texture.New2D(GraphicsDevice, 512, 512, PixelFormat.D16_UNorm, TextureFlags.DepthStencil).DisposeBy(this); width = GraphicsDevice.BackBuffer.ViewWidth; height = GraphicsDevice.BackBuffer.ViewHeight; }
/// <summary> /// エフェクトにマトリックスを適用 /// </summary> /// <param name="mode">描画モード</param> /// <param name="world">ワールド</param> public virtual void SetParams(MMDDrawingMode mode, ref Matrix world) { Matrix view, projection; //カメラ情報の取得 Viewport viewport = effect.Device.Viewport; float aspectRatio = (float)viewport.Width / (float)viewport.Height; SlimMMDXCore.Instance.Camera.GetCameraParam(aspectRatio, out view, out projection); //マトリクス処理 effect.SetValue("World", world); effect.SetValue("View", view); effect.SetValue("Projection", projection); effect.SetValue("EyePosition", SlimMMDXCore.Instance.Camera.Position); //ライティング処理 Vector3 color, dir; SlimMMDXCore.Instance.Light.GetLightParam(out color, out dir); effect.SetValue("AmbientLightColor", color); effect.SetValue("DirLight0Direction", dir); switch (mode) { case MMDDrawingMode.Normal: effect.Technique = "MMDEffect"; break; case MMDDrawingMode.Edge: effect.Technique = "MMDNormalDepth"; break; default: throw new NotImplementedException(); } }
/// <summary> /// Initializes a new instance of the <see cref="UserQR"/> class. This object will compute the /// QR factorization when the constructor is called and cache it's factorization. /// </summary> /// <param name="matrix">The matrix to factor.</param> /// <param name="method">The QR factorization method to use.</param> /// <exception cref="ArgumentNullException">If <paramref name="matrix"/> is <c>null</c>.</exception> public static UserQR Create(Matrix<Complex> matrix, QRMethod method = QRMethod.Full) { if (matrix.RowCount < matrix.ColumnCount) { throw Matrix.DimensionsDontMatch<ArgumentException>(matrix); } Matrix<Complex> q; Matrix<Complex> r; var minmn = Math.Min(matrix.RowCount, matrix.ColumnCount); var u = new Complex[minmn][]; if (method == QRMethod.Full) { r = matrix.Clone(); q = Matrix<Complex>.Build.SameAs(matrix, matrix.RowCount, matrix.RowCount); for (var i = 0; i < matrix.RowCount; i++) { q.At(i, i, 1.0f); } for (var i = 0; i < minmn; i++) { u[i] = GenerateColumn(r, i, i); ComputeQR(u[i], r, i, matrix.RowCount, i + 1, matrix.ColumnCount, Control.MaxDegreeOfParallelism); } for (var i = minmn - 1; i >= 0; i--) { ComputeQR(u[i], q, i, matrix.RowCount, i, matrix.RowCount, Control.MaxDegreeOfParallelism); } } else { q = matrix.Clone(); for (var i = 0; i < minmn; i++) { u[i] = GenerateColumn(q, i, i); ComputeQR(u[i], q, i, matrix.RowCount, i + 1, matrix.ColumnCount, Control.MaxDegreeOfParallelism); } r = q.SubMatrix(0, matrix.ColumnCount, 0, matrix.ColumnCount); q.Clear(); for (var i = 0; i < matrix.ColumnCount; i++) { q.At(i, i, 1.0f); } for (var i = minmn - 1; i >= 0; i--) { ComputeQR(u[i], q, i, matrix.RowCount, i, matrix.ColumnCount, Control.MaxDegreeOfParallelism); } } return new UserQR(q, r, method); }
/// <summary> /// Constructor or added a new light to the scene /// </summary> /// <param name="type">the light type you wish to have or default of point</param> public LightClass(LightType type = LightType.Point) { if (type == LightType.Point) { light.Type = type; light.Diffuse = Color.White; light.Ambient = Color.White; light.Specular = Color.White; light.Position = Vector3.Zero; light.Range = 100.0f; } else if (type == LightType.Directional) { light.Type = type; light.Direction = Vector3.Zero; light.Ambient = Color.White; light.Diffuse = Color.White; light.Specular = Color.White; light.Range = 100.0f; } isLightEnabled = false; Type = type.ToString(); Position = Vector3.Zero; Direction = Vector3.Zero; world = Matrix.Identity; mesh = Mesh.CreateSphere(DeviceManager.LocalDevice, .1f, 10, 10); material.Diffuse = Color.White; material.Ambient = Color.White; DeviceManager.LocalDevice.Material = material; }
public void TestCreateMatrix() { var matrix = new Matrix<int>(2, 2); var other_matrix = matrix.CreateMatrix(3, 3); Assert.IsInstanceOfType(matrix.GetType(), other_matrix); }
public bool Initialize(Device device, DeviceContext deviceContext, IntPtr windowHandle, int screanWidth, int screenHeight, Matrix baseViewMatrix) { // Store the screen width and height. ScreenWidth = screanWidth; ScreenHeight = screenHeight; // Store the base view matrix. BaseViewMatrix = baseViewMatrix; // Create the font object. Font = new Font(); // Initialize the font object. if (!Font.Initialize(device, "fontdata.txt", "font.dds")) return false; // Create the font shader object. FontShader = new FontShader(); // Initialize the font shader object. if (!FontShader.Initialize(device, windowHandle)) return false; // Initialize the first sentence. if (!InitializeSentence(out sentences[0], 32, device)) return false; // Now update the sentence vertex buffer with the new string information. if (!UpdateSentece(ref sentences[0], "Render Count:", 20, 20, 1, 1, 1, deviceContext)) return false; return true; }
public TextureConverter(uint[] data, int width, byte? alphaTolerance, float? hullTolerance, bool? holeDetection, bool? multipartDetection, bool? pixelOffsetOptimization, Matrix? transform) { Initialize(data, width, alphaTolerance, hullTolerance, holeDetection, multipartDetection, pixelOffsetOptimization, transform); }
public void Render(DeviceContext dc, EffectPass pass, Matrix view, Matrix proj) { var position = Particle.Position; Model.World = Matrix.Translation(position); Model.Draw(dc, pass, view, proj); }
/// <summary> /// Gets a transform that maps abstract coordinates to DIPs. /// </summary> /// <param name="clientDrawingContext">The drawing context passed to <see cref="SharpDX.DirectWrite.TextLayout.Draw_"/>.</param> /// <returns>a structure which has transform information for pixel snapping.</returns> /// <unmanaged>HRESULT GetCurrentTransform([None] void* clientDrawingContext,[Out] DWRITE_MATRIX* transform)</unmanaged> public virtual Matrix GetCurrentTransform(object clientDrawingContext) { Matrix matrix = new Matrix(); matrix.M11 = 1; matrix.M22 = 1; return matrix; }
public override void DrawBox(ref Vector3 bbMin, ref Vector3 bbMax, ref Matrix trans, Color color) { var p1 = Vector3.TransformCoordinate(bbMin, trans); var p2 = Vector3.TransformCoordinate(new Vector3(bbMax.X, bbMin.Y, bbMin.Z), trans); var p3 = Vector3.TransformCoordinate(new Vector3(bbMax.X, bbMax.Y, bbMin.Z), trans); var p4 = Vector3.TransformCoordinate(new Vector3(bbMin.X, bbMax.Y, bbMin.Z), trans); var p5 = Vector3.TransformCoordinate(new Vector3(bbMin.X, bbMin.Y, bbMax.Z), trans); var p6 = Vector3.TransformCoordinate(new Vector3(bbMax.X, bbMin.Y, bbMax.Z), trans); var p7 = Vector3.TransformCoordinate(bbMax, trans); var p8 = Vector3.TransformCoordinate(new Vector3(bbMin.X, bbMax.Y, bbMax.Z), trans); int intColor = ColorToInt(ref color); lines.Add(new PositionColored(ref p1, intColor)); lines.Add(new PositionColored(ref p2, intColor)); lines.Add(new PositionColored(ref p2, intColor)); lines.Add(new PositionColored(ref p3, intColor)); lines.Add(new PositionColored(ref p3, intColor)); lines.Add(new PositionColored(ref p4, intColor)); lines.Add(new PositionColored(ref p4, intColor)); lines.Add(new PositionColored(ref p1, intColor)); lines.Add(new PositionColored(ref p1, intColor)); lines.Add(new PositionColored(ref p5, intColor)); lines.Add(new PositionColored(ref p2, intColor)); lines.Add(new PositionColored(ref p6, intColor)); lines.Add(new PositionColored(ref p3, intColor)); lines.Add(new PositionColored(ref p7, intColor)); lines.Add(new PositionColored(ref p4, intColor)); lines.Add(new PositionColored(ref p8, intColor)); lines.Add(new PositionColored(ref p5, intColor)); lines.Add(new PositionColored(ref p6, intColor)); lines.Add(new PositionColored(ref p6, intColor)); lines.Add(new PositionColored(ref p7, intColor)); lines.Add(new PositionColored(ref p7, intColor)); lines.Add(new PositionColored(ref p8, intColor)); lines.Add(new PositionColored(ref p8, intColor)); lines.Add(new PositionColored(ref p5, intColor)); }
/// <summary> /// Crear un modelo adjunto a un hueso /// </summary> /// <param name="model">Modelo a adjuntar</param> /// <param name="bone">Hueso al cual adjuntarse</param> /// <param name="offset">Offset desde el cual el modelo sigue al hueso</param> public TgcSkeletalBoneAttach(TgcMesh mesh, TgcSkeletalBone bone, Matrix offset) { this.bone = bone; this.mesh = mesh; this.offset = offset; updateValues(); }
public SyntheticData() { state = new Matrix<float>(4, 1); state[0, 0] = Cursor.Position.X; // x-pos state[1, 0] = Cursor.Position.Y; // y-pos state[2, 0] = 0f; // x-velocity state[3, 0] = 0f; // y-velocity transitionMatrix = new Matrix<float>(new float[,] { {1, 0, 1, 0}, {0, 1, 0, 1}, {0, 0, 1, 0}, {0, 0, 0, 1} }); measurementMatrix = new Matrix<float>(new float[,] { { 1, 0, 0, 0 }, { 0, 1, 0, 0 } }); measurementMatrix.SetIdentity(); processNoise = new Matrix<float>(4, 4); processNoise.SetIdentity(new MCvScalar(1.0e-4)); measurementNoise = new Matrix<float>(2, 2); measurementNoise.SetIdentity(new MCvScalar(1.5e-1)); errorCovariancePost = new Matrix<float>(4, 4); errorCovariancePost.SetIdentity(); }
public MinkowskiSumShape(ConvexShape shapeA, ConvexShape shapeB) { _shapeA = shapeA; _shapeB = shapeB; _transformA = Matrix.Identity; _transformB = Matrix.Identity; }
public void Reset() { _matrix = _matrixInverse = Matrix.Identity; _rotation = new Vector3(); _scale = new Vector3(1.5f); _z = 0.0f; }