/// <summary> /// Két vektor akkor egyenlõ, ha ugyanabból a pontból indulnak ki és ugyanabban az irányba /// mutatnak és hosszuk is megegyezik. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (obj == null) { return(false); } if (this.GetType() != obj.GetType()) { return(false); } Vector other = (Vector)obj; if (!X.Equals(other.X)) { return(false); } if (!Y.Equals(other.Y)) { return(false); } if (!Vx.Equals(other.Vx)) { return(false); } if (!Vy.Equals(other.Vy)) { return(false); } return(true); }
private void InResultUnits() { X = X.Convert(Settings.Quantities.Units.Length); Y = Y.Convert(Settings.Quantities.Units.Length); Vx = Vx.Convert(Settings.Quantities.Units.Velocity); Vy = Vy.Convert(Settings.Quantities.Units.Velocity); T = T.Convert(Settings.Quantities.Units.Time); }
private Point2D Normalize(Point2D point) { var oPoint = point - Origin; var xcor = Vx.Normalize().DotProduct(oPoint / Vx.Length) * 3; var ycor = Vy.Normalize().DotProduct(oPoint / Vy.Length) * 3; return(new Point2D(xcor, ycor)); }
public void ResetRealTime() { X.RealTimeToSource(); Y.RealTimeToSource(); Rad.RealTimeToSource(); Vx.RealTimeToSource(); Vy.RealTimeToSource(); F.RealTimeToSource(); R.RealTimeToSource(); G.RealTimeToSource(); B.RealTimeToSource(); }
public HarmonicOscillatorModelingResultViewModel(Tuple <List <double>, List <double>, List <double>, List <double> > numeric) { for (var i = 0; i < numeric.Item1.Count; ++i) { Xt.Add(new ObservablePoint(numeric.Item1[i], numeric.Item2[i])); Vt.Add(new ObservablePoint(numeric.Item1[i], numeric.Item3[i])); E.Add(new ObservablePoint(numeric.Item1[i], numeric.Item4[i])); Vx.Add(new ObservablePoint(numeric.Item2[i], numeric.Item3[i])); } Collection.Add(new LineSeries() { Values = Xt }); }
public string to_string() { string str = n.ToString() + " " + nj.ToString() + " " + nx.ToString() + "\r\n"; str += Lj.ToString() + " " + Lx.ToString() + "\r\n"; str += Vj.ToString() + " " + Vx.ToString() + "\r\n"; str += Cj.ToString() + " " + Cx.ToString() + "\r\n"; str += Pt.ToString() + " " + At.ToString() + "\r\n"; foreach (var t in targets) { str += t.to_string() + "\r\n"; } return(str); }
static void Main(string[] args) { Vx.Initialize(); VxModel cessnaModel = new VxModel("Models/cessna.obj"); VxModel trumpetModel = new VxModel("Models/trumpet.obj"); VxCamera camera = new VxCamera(); while (Vx.IsRunning) { camera.Update(); Vx.Model(cessnaModel); Vx.Position(0, 1, -1); Vx.Scale(1); Vx.SolidColor(RgbaFloat.Red); Vx.Draw(); Vx.Model(trumpetModel); Vx.Position(0, 10, -1); Vx.Scale(0.05f); Vx.SolidColor(RgbaFloat.Yellow); Vx.Draw(); Vx.Model(VxModel.Cube); Vx.Position(3, 5, -9); Vx.Scale(3); Vx.SolidColor(RgbaFloat.Blue); Vx.Draw(); Vx.Position(-3, 2, -1); Vx.Scale(1.5f); Vx.SolidColor(RgbaFloat.Yellow); Vx.Draw(); Vx.SolidColor(RgbaFloat.White); Vx.Scale(0.075f); for (int i = 0; i < 10; i++) { Vx.Position(-4.15f + i * 0.175f, 3f, -1f); Vx.Rotation(Quaternion.CreateFromAxisAngle(-Vector3.UnitZ, i * 0.2f)); Vx.Draw(); } Vx.EndFrame(); } Vx.Terminate(); }
private void AddVoxelIJL(IJL ijl) { if (!_sampleset.Add(ijl)) { return; } IJL chunk = Vx.ChunkIJL(ijl, chunk_radius); if (!_chunkmap.ContainsKey(chunk)) { _chunkmap.Add(chunk, new List <IJL>()); _chunklist.Add(chunk); } _chunkmap[chunk].Add(ijl - Vx.ChunkVoxelIJL(chunk, chunk_radius)); }
private void InitializeChunkObject(int index) { if (index < 0 || index >= _chunkobjs.Count || _chunkobjs[index] != null) { return; } IJL chunk = _chunksobj_ijls[index]; _chunkobjs[index] = new GameObject("Chunk " + chunk.ToString()); _chunkobjs[index].transform.localPosition = VMD.VoxelVertex(Vx.ChunkVoxelIJL(chunk, chunk_radius)); _chunkobjs[index].AddComponent <MeshFilter>(); MeshRenderer renderer = _chunkobjs[index].AddComponent <MeshRenderer>(); renderer.sharedMaterial = material; }
private void UpdateChunkMesh(IJL chunk) { if (!_chunkobjmap.ContainsKey(chunk) || !_chunkmap.ContainsKey(chunk)) { return; } _data.Clear(); _data.flat_shaded = flat_shaded; _data.map = voxelstyle; int cnt = Vx.AdjBlockIJL.Length; IJL chunkvoxel = Vx.ChunkVoxelIJL(chunk, chunk_radius); List <IJL> voxels = _chunkmap[chunk]; for (int k = 0; k < voxels.Count; k++) { _data.UpdateVoxelData(voxels[k], new Voxel(1), true); IJL voxelijl = chunkvoxel + voxels[k]; for (int cell_index = 0; cell_index < cnt; cell_index++) { IJL adjvoxel = voxelijl + Vx.AdjBlockIJL[cell_index]; if (Vx.ChunkIJL(adjvoxel, chunk_radius) == chunk) { continue; } if (!_sampleset.Contains(adjvoxel)) { continue; } _data.UpdateVoxelData(voxels[k] + Vx.AdjBlockIJL[cell_index], new Voxel(1), false); } } _data.UpdateDirtyComponents(); _data.GenerateMesh(); MeshFilter filter = _chunkobjmap[chunk].GetComponent <MeshFilter>(); if (filter.mesh == null) { filter.mesh = new Mesh(); } filter.mesh.SetVertices(_data.vertices); filter.mesh.SetNormals(_data.normals); filter.mesh.SetTriangles(_data.triangles, 0); filter.mesh.RecalculateBounds(); filter.mesh.RecalculateTangents(); filter.mesh.UploadMeshData(false); }
/// <summary> /// Do not use with SCALE or FREERECT at same time! /// </summary> public void ScaleVec(EasingType easingEnum, int startTime, int endTime, float startVx, float startVy, float endVx, float endVy) { float ms = _timing.Offset; if (!IsFinished && ms >= startTime && ms <= endTime) { var t = (ms - startTime) / (endTime - startTime); Vx.RealTime = startVx + (float)easingEnum.Ease(t) * (endVx - startVx); Vy.RealTime = startVy + (float)easingEnum.Ease(t) * (endVy - startVy); } if (ms >= VTime.Max) { Vx.RealTimeToTarget(); Vy.RealTimeToTarget(); } }
private int VertexCast(Vector2 viewpos) { Ray ray = _previewutility.camera.ViewportPointToRay(viewpos); if (ray.direction == Vector3.zero || target == null || target.vertices == null) { return(-1); } PatternMatch match = new PatternMatch(invx, invy, 0); float nearest_t = Mathf.Infinity; int nearest_sphere = -1; float near_clip = _previewutility.camera.nearClipPlane; float far_clip = _previewutility.camera.farClipPlane; List <Vector3> vertices = target.vertices; for (int k = 0; k < vertices.Count; k++) { Vector3 vertex = Vx.TransformVertex(vertices[k], Vx.ReflVector, match); Vector3 point_vector = ray.origin - vertex; float proj_pv = Vector3.Dot(ray.direction, point_vector); float sqr_magn = Vector3.SqrMagnitude(point_vector - (proj_pv * ray.direction)); //check if ray intersects point if (sqr_magn > VxlGUI.POINT_RADIUSSQR) { continue; } //get t of impact and check if in range float t = Mathf.Abs(proj_pv) - Mathf.Sqrt(Mathf.Max(0, VxlGUI.POINT_RADIUSSQR - sqr_magn)); if (t < near_clip || t > far_clip) { continue; } if (t >= nearest_t) { continue; } nearest_t = t; nearest_sphere = k; } return(nearest_sphere); }
private void UpdateMesh() { _meshvertex.Clear(); _meshnormals.Clear(); _meshuvs.Clear(); _meshtriangles.Clear(); _mesh.Clear(); if (target == null || !target.IsValid()) { UploadMeshChanges(); return; } bool flip = (invx && !invy) || (!invx && invy); PatternMatch match = new PatternMatch(invx, invy, 0); List <Vector3> vertices = target.vertices; List <Triangle> triangles = target.triangles; for (int k = 0; k < triangles.Count; k++) { Triangle tri = triangles[k]; if (!tri.IsValid(vertices.Count, null, null)) { continue; } if (flip) { tri = Triangle.Flip(tri); } Vector2 uv = GetTriangleUV(k); Vector3 vertex0 = Vx.TransformVertex(vertices[tri.vertex0], Vx.ReflVector, match); Vector3 vertex1 = Vx.TransformVertex(vertices[tri.vertex1], Vx.ReflVector, match); Vector3 vertex2 = Vx.TransformVertex(vertices[tri.vertex2], Vx.ReflVector, match); AddTriangle(vertex0, vertex1, vertex2, uv); } UploadMeshChanges(); }
/* Simulacija koristeci Eulerov metod*/ public void simulationEuler() { /* FUNKCIONALNE PROMENLJIVE */ int i = 0; //brojac iteracija bool simulationRunning = true; // promenljiva za pokretanje/prekidanje simulacije /* Stil za oznacavanje zapisa */ DataGridViewCellStyle boja = new DataGridViewCellStyle(); boja.ForeColor = Color.DarkOrange; boja.Font = new Font(Tabela.Font, FontStyle.Bold); double axPrim; double ayPrim; double axSec; double aySec; PointD[] points = { new PointD(865, 0.296221041243509), new PointD(815, 0.362064203509306), new PointD(776, 0.371578055743002), new PointD(737, 0.382525045298620), new PointD(700, 0.382835165547702), new PointD(664, 0.384235165547702), new PointD(629, 0.385786703294031), }; try { while (simulationRunning) { /* Upis podataka u datagridview */ string[] row = new string[] { posX.ToString(), posY.ToString(), V.ToString(), Vx.ToString(), Vy.ToString(), ax.ToString(), ay.ToString(), Fd.ToString(), Cd.ToString(), (currAngle * 180 / Math.PI).ToString() }; Tabela.Rows.Add(row); Tabela.Rows[Tabela.Rows.Count - 2].DefaultCellStyle = boja; /* Upis u grafik */ Grafik.Series[3].Points.AddXY(posX, posY); // crtanje pozicije na grafiku Grafik1.Series[3].Points.AddXY(posX, V); // crtanje pozicije na grafiku /* Ugao vektora brzine i apscise */ angleA = g / V * Math.Cos(currAngle); angleSpeed = angleSpeed + angleA * interval; currAngle = Math.Atan(Vy / Vx) - angleSpeed * interval; /* Racunanje vremena leta */ t += interval; /* pomeranje projektila */ posX = posX + Vx * interval - 0.5 * Math.Pow(interval, 2) * ax; // pomeranje po X osi posY = posY + Vy * interval - 0.5 * Math.Pow(interval, 2) * ay; // pomeranje po Y osi /* Trenutna brzina */ V = Math.Sqrt(Math.Pow(Vx, 2) + Math.Pow(Vy, 2)); //racunanje efektivne vrednosti vektora brzine /* otpor vazduha IMPLEMENTIRATI INTERPOLACIJU ZA Cx */ Cd = LinearFunctionD.LinearInterpolationY(V, points); Fd = Cd * airDensity * S * Math.Pow(Vx, 2) * 0.5; //racunanje sile otpora vazduha /* Racunanje ubraznja */ axPrim = airDensity * S * Cd * Vx * ax; ayPrim = airDensity * S * Cd * Vy * ay; axSec = airDensity * S * Cd * axPrim; aySec = airDensity * S * Cd * ayPrim; ax = Fd * Math.Cos(currAngle) / m + axPrim * interval + 0.5 * Math.Pow(interval, 2) * axSec; ay = g + Fd * Math.Sin(currAngle) / m + ayPrim * interval + 0.5 * Math.Pow(interval, 2) * aySec; /* promena brzine u intervalu vremena */ Vx = Vx - ax * interval - 0.5 * Math.Pow(interval, 2) * axPrim; Vy = Vy - ay * interval - 0.5 * Math.Pow(interval, 2) * axPrim; /* USLOV ZA PREKIDANJE SIMULACIJE */ if (posY < -1) { simulationRunning = false; //MessageBox.Show("Vreme leta:" + t + "s"); } i++; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/* Simulacija u uslovima vakuuma */ public void simulationVacuum() { /* FUNKCIONALNE PROMENLJIVE */ int i = 0; //brojac iteracija bool simulationRunning = true; // promenljiva za pokretanje/prekidanje simulacije /* Stil za oznacavanje zapisa */ DataGridViewCellStyle boja = new DataGridViewCellStyle(); boja.ForeColor = Color.ForestGreen; boja.Font = new Font(Tabela.Font, FontStyle.Bold); try { while (simulationRunning) { /* Upis podataka u datagridview */ string[] row = new string[] { posX.ToString(), posY.ToString(), V.ToString(), Vx.ToString(), Vy.ToString(), ax.ToString(), ay.ToString(), Fd.ToString(), Cd.ToString(), (currAngle * 180 / Math.PI).ToString() }; Tabela.Rows.Add(row); Tabela.Rows[Tabela.Rows.Count - 2].DefaultCellStyle = boja; /* Upis u grafik */ Grafik.Series[2].Points.AddXY(posX, posY); // crtanje pozicije na grafiku Grafik1.Series[2].Points.AddXY(posX, V); // crtanje pozicije na grafiku /* Racunanje vremena leta */ t += interval; /* pomeranje projektila */ posX = posX + Vx * interval; // pomeranje po X osi posY = posY + Vy * interval; // pomeranje po Y osi /* Trenutna brzina */ V = Math.Sqrt(Math.Pow(Vx, 2) + Math.Pow(Vy, 2)); //racunanje efektivne vrednosti vektora brzine /* Racunanje ubrzanja */ ay = g; /* promena brzine u intervalu vremena */ Vy = Vy - ay * interval; /* USLOV ZA PREKIDANJE SIMULACIJE */ if (posY < -1) { simulationRunning = false; //MessageBox.Show("Vreme leta:" + t + "s"); } i++; } // Tabela.Rows.Add(emptyRow); // Tabela.Rows[Tabela.Rows.Count - 2].DefaultCellStyle = zeleni; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public override string ToString() { return($"{base.ToString()} SHL V[{Vx.ToString(ByteFormat)}]{{, V[{Vy.ToString(ByteFormat)}]}}"); }
public override string ToString() { return($"{base.ToString()} RND V[{Vx.ToString(ByteFormat)}], {Value.ToString(ByteFormat)}"); }
/* Simulacija sa otporom vazduha - prediktor-korektor */ public void simulationAdams() { /* FUNKCIONALNE PROMENLJIVE */ bool simulationRunning = true; // promenljiva za pokretanje/prekidanje simulacije /* Stil za oznacavanje zapisa */ DataGridViewCellStyle boja = new DataGridViewCellStyle(); boja.ForeColor = Color.DarkCyan; boja.Font = new Font(Tabela.Font, FontStyle.Bold); //promenljive za poziciju, brzinu i ubrzanje - nizovi zbog koraka prediktor-korektor metode double[] posXPC = new double[3]; double[] posYPC = new double[3]; double[] VxPC = new double[3]; double[] VyPC = new double[3]; double[] axPC = new double[3]; double[] ayPC = new double[3]; double[] currAnglePC = new double[3]; double[] angleSpeedPC = new double[3]; double[] angleAPC = new double[3]; //promenljive za poziciju, brzinu i ubrzanje - nizovi zbog koraka adamsovog metod double[] posXStep = new double[5]; double[] posYStep = new double[5]; double[] VxStep = new double[5]; double[] VyStep = new double[5]; double[] axStep = new double[5]; double[] ayStep = new double[5]; double[] currAngleStep = new double[5]; double[] angleSpeedStep = new double[5]; double[] angleAStep = new double[5]; PointD[] points = { new PointD(865, 0.296221041243509), new PointD(815, 0.362064203509306), new PointD(776, 0.371578055743002), new PointD(737, 0.382525045298620), new PointD(700, 0.382835165547702), new PointD(664, 0.384235165547702), new PointD(629, 0.385786703294031), }; try { /* FOR petlja za popunjavanje cetiri koraka metode*/ for (int i = 0; i < 5; i++) { /* Upis podataka u datagridview */ string[] row = new string[] { posX.ToString(), posY.ToString(), V.ToString(), Vx.ToString(), Vy.ToString(), ax.ToString(), ay.ToString(), Fd.ToString(), Cd.ToString(), (currAngle * 180 / Math.PI).ToString() }; Tabela.Rows.Add(row); Tabela.Rows[Tabela.Rows.Count - 2].DefaultCellStyle = boja; /* Upis u grafik */ Grafik.Series[4].Points.AddXY(posX, posY); // crtanje pozicije na grafiku Grafik1.Series[4].Points.AddXY(posX, V); // crtanje pozicije na grafiku /* PREDIKTOR start */ /* Ugao vektora brzine i apscise */ angleAPC[0] = g / V * Math.Cos(currAngle); angleSpeedPC[0] = angleSpeedPC[0] + angleAPC[0] * interval; currAnglePC[0] = Math.Atan(Vy / Vx) - angleSpeedPC[0] * interval; /* Racunanje vremena leta */ t += interval; /* pomeranje projektila */ posXPC[0] = posX + Vx * interval; // pomeranje po X osi posYPC[0] = posY + Vy * interval; // pomeranje po Y osi /* Trenutna brzina */ V = Math.Sqrt(Math.Pow(Vx, 2) + Math.Pow(Vy, 2)); //racunanje efektivne vrednosti vektora brzine /* otpor vazduha*/ Cd = LinearFunctionD.LinearInterpolationY(V, points); Fd = Cd * airDensity * S * Math.Pow(Vx, 2) * 0.5; //racunanje sile otpora vazduha /* Racunanje ubraznja */ axPC[0] = Fd * Math.Cos(currAngle) / m; ayPC[0] = g + Fd * Math.Sin(currAngle) / m; /* promena brzine u intervalu vremena */ VxPC[0] = Vx - ax * interval; VyPC[0] = Vy - ay * interval; /* Ugao vektora brzine i apscise */ angleAPC[1] = g / V * Math.Cos(currAnglePC[0]); angleSpeedPC[1] = angleSpeedPC[0] + angleAPC[1] * interval; currAnglePC[1] = Math.Atan(VyPC[0] / VxPC[0]) - angleSpeedPC[1] * interval; /* Racunanje vremena leta */ t += interval; /* pomeranje projektila */ posXPC[1] = posXPC[0] + VxPC[0] * interval; // pomeranje po X osi posYPC[1] = posYPC[0] + VyPC[0] * interval; // pomeranje po Y osi /* Trenutna brzina */ V = Math.Sqrt(Math.Pow(Vx, 2) + Math.Pow(Vy, 2)); //racunanje efektivne vrednosti vektora brzine /* otpor vazduha IMPLEMENTIRATI INTERPOLACIJU ZA Cx */ Cd = LinearFunctionD.LinearInterpolationY(V, points); Fd = Cd * airDensity * S * Math.Pow(VxPC[0], 2) * 0.5; //racunanje sile otpora vazduha /* Racunanje ubrzanja */ axPC[1] = Fd * Math.Cos(currAngle) / m; ayPC[1] = g + Fd * Math.Sin(currAngle) / m; /* promena brzine u intervalu vremena */ VxPC[1] = VxPC[0] - axPC[0] * interval; VyPC[1] = VyPC[0] - ayPC[0] * interval; /* PREDIKTOR end*/ /* KOREKTOR start */ axPC[2] = (axPC[0] + axPC[1]) / 2.0; ayPC[2] = (ayPC[0] + ayPC[1]) / 2.0; VxPC[2] = (VxPC[0] + VxPC[1]) / 2.0; VyPC[2] = (VyPC[0] + VyPC[1]) / 2.0; posXPC[2] = (posXPC[0] + posXPC[1]) / 2.0; posYPC[2] = (posYPC[0] + posYPC[1]) / 2.0; angleAPC[2] = (angleAPC[0] + angleAPC[1]) / 2.0; angleSpeedPC[2] = (angleSpeedPC[0] + angleSpeedPC[1]) / 2.0; currAnglePC[2] = (currAnglePC[0] + currAnglePC[1]) / 2.0; ax = axPC[2]; ay = ayPC[2]; Vx = VxPC[2]; Vy = VyPC[2]; posX = posXPC[2]; posY = posYPC[2]; angleA = angleAPC[2]; angleSpeed = angleSpeedPC[2]; currAngle = currAnglePC[2]; V = Math.Sqrt(Math.Pow(Vx, 2) + Math.Pow(Vy, 2)); /*KOREKTOR end */ /* Promenljive za 4 koraka adams metode start */ axStep[i] = ax; ayStep[i] = ay; VxStep[i] = Vx; VyStep[i] = Vy; posXStep[i] = posX; posYStep[i] = posY; angleAStep[i] = angleA; angleSpeedStep[i] = angleSpeed; currAngleStep[i] = currAngle; /* Promenljive za 4 koraka adams metode end */ /* USLOV ZA PREKIDANJE SIMULACIJE */ if (posY < -1) { simulationRunning = false; //MessageBox.Show("Vreme leta:" + t + "s"); } } while (simulationRunning) { /* Upis podataka u datagridview */ string[] row = new string[] { posX.ToString(), posY.ToString(), V.ToString(), Vx.ToString(), Vy.ToString(), ax.ToString(), ay.ToString(), Fd.ToString(), Cd.ToString(), (currAngle * 180 / Math.PI).ToString() }; Tabela.Rows.Add(row); Tabela.Rows[Tabela.Rows.Count - 2].DefaultCellStyle = boja; /* Upis u grafik */ Grafik.Series[4].Points.AddXY(posX, posY); // crtanje pozicije na grafiku Grafik1.Series[4].Points.AddXY(posX, V); // crtanje pozicije na grafiku /* PREDIKTOR start */ /* Ugao vektora brzine i apscise */ angleA = g / V * Math.Cos(currAngle); angleSpeed = angleSpeed + angleA * interval; currAngle = Math.Atan(Vy / Vx) - angleSpeed * interval; /* Racunanje vremena leta */ t += interval; /* pomeranje projektila */ // pomeranje po X osi posX = posX + interval / 24 * (55 * VxStep[3] - 59 * VxStep[2] + 37 * VxStep[1] - 9 * VxStep[0]); // pomeranje po Y osi posY = posY + interval / 24 * (55 * VyStep[3] - 59 * VyStep[2] + 37 * VyStep[1] - 9 * VyStep[0]);; /* Trenutna brzina */ V = Math.Sqrt(Math.Pow(Vx, 2) + Math.Pow(Vy, 2)); //racunanje efektivne vrednosti vektora brzine /* otpor vazduha*/ Cd = LinearFunctionD.LinearInterpolationY(V, points); Fd = Cd * airDensity * S * Math.Pow(Vx, 2) * 0.5; //racunanje sile otpora vazduha /* Racunanje ubraznja */ ax = Fd * Math.Cos(currAngle) / m; ay = g + Fd * Math.Sin(currAngle) / m; /* promena brzine u intervalu vremena */ Vx = Vx - interval / 24 * (55 * axStep[3] - 59 * axStep[2] + 37 * axStep[1] - 9 * axStep[0]); Vy = Vy - interval / 24 * (55 * ayStep[3] - 59 * ayStep[2] + 37 * ayStep[1] - 9 * ayStep[0]);; for (int i = 0; i < 3; i++) { VxStep[i] = VxStep[i + 1]; VyStep[i] = VyStep[i + 1]; axStep[i] = axStep[i + 1]; ayStep[i] = ayStep[i + 1]; } VxStep[3] = Vx; VyStep[3] = Vy; axStep[3] = ax; ayStep[3] = ay; /* USLOV ZA PREKIDANJE SIMULACIJE */ if (posY < -1) { simulationRunning = false; //MessageBox.Show("Vreme leta:" + t + "s"); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public override int GetHashCode() { int hash = 1; if (X != 0F) { hash ^= X.GetHashCode(); } if (Y != 0F) { hash ^= Y.GetHashCode(); } if (Vx != 0F) { hash ^= Vx.GetHashCode(); } if (Vy != 0F) { hash ^= Vy.GetHashCode(); } if (Rotation != 0F) { hash ^= Rotation.GetHashCode(); } if (Omega != 0F) { hash ^= Omega.GetHashCode(); } if (InitLife != 0F) { hash ^= InitLife.GetHashCode(); } if (Life != 0F) { hash ^= Life.GetHashCode(); } if (Scale != 0F) { hash ^= Scale.GetHashCode(); } if (Alpha != 0F) { hash ^= Alpha.GetHashCode(); } if (Mass != 0F) { hash ^= Mass.GetHashCode(); } if (IsDead != false) { hash ^= IsDead.GetHashCode(); } if (ColorR != 0F) { hash ^= ColorR.GetHashCode(); } if (ColorG != 0F) { hash ^= ColorG.GetHashCode(); } if (ColorB != 0F) { hash ^= ColorB.GetHashCode(); } if (CurrentAnimationFrame != 0) { hash ^= CurrentAnimationFrame.GetHashCode(); } return(hash); }
private void DrawVertex() { if (target == null || !target.IsValid()) { return; } if (vertex_mesh == null || vertex_mat == null) { return; } if (_vertexmode == VertexMode.None) { return; } PatternMatch match = new PatternMatch(invx, invy, 0); List <Vector3> vectors = target.vertices; if (_vertexmode == VertexMode.PrimarySelectTriangle) { int super_vertex0 = -1; int super_vertex1 = -1; int super_vertex2 = -1; HashSet <int> trivertex = new HashSet <int>(); List <Triangle> triangles = target.triangles; for (int k = 0; k < _primarylist.Count; k++) { int tri_index = _primarylist[k]; if (tri_index < 0 || tri_index >= triangles.Count) { continue; } Triangle tri = triangles[tri_index]; if (!tri.IsValid(vectors.Count, null, null)) { continue; } trivertex.Add(tri.vertex0); trivertex.Add(tri.vertex1); trivertex.Add(tri.vertex2); if (k == _primarylist.Count - 1) { super_vertex0 = tri.vertex0; super_vertex1 = tri.vertex1; super_vertex2 = tri.vertex2; } } for (int k = 0; k < vectors.Count; k++) { bool primary_superselect = false; bool primary_select = trivertex.Contains(k); if (primary_select) { primary_superselect = (super_vertex0 == k) || (super_vertex1 == k) || (super_vertex2 == k); } bool secondary_superselect = false; bool secondary_select = _secondarytset.Contains(k); if (secondary_select) { secondary_superselect = _secondarylist[_secondarylist.Count - 1] == k; } SetMaterialBlock(primary_select, primary_superselect, secondary_select, secondary_superselect); _previewutility.DrawMesh(vertex_mesh, Vx.TransformVertex(vectors[k], Vx.ReflVector, match), Quaternion.identity, vertex_mat, 0, _previewblock); } } else { for (int k = 0; k < vectors.Count; k++) { bool primary_superselect = false; bool primary_select = _primarytset.Contains(k); if (primary_select) { primary_superselect = _primarylist[_primarylist.Count - 1] == k; } bool secondary_superselect = false; bool secondary_select = _secondarytset.Contains(k); if (secondary_select) { secondary_superselect = _secondarylist[_secondarylist.Count - 1] == k; } SetMaterialBlock(primary_select, primary_superselect, secondary_select, secondary_superselect); _previewutility.DrawMesh(vertex_mesh, Vx.TransformVertex(vectors[k], Vx.ReflVector, match), Quaternion.identity, vertex_mat, 0, _previewblock); } } }
public override string ToString() { return($"{base.ToString()} DRW V[{Vx.ToString(ByteFormat)}], V[{Vy.ToString(ByteFormat)}], {Height.ToString(ByteFormat)}"); }
protected void SetMinMax() { // 与bitmapObject不同,由于sb是纯静态的,所以可先判断出范围,为提高效率,这里先进行计算 if (_element.FadeList.Count > 0) { FadeTime = new TimeRange { Min = (int)_element.FadeList.Min(k => k.StartTime), Max = (int)_element.FadeList.Max(k => k.EndTime), }; F.Source = _element.FadeList.First().F1; F.Target = _element.FadeList.Last().F2; } if (_element.RotateList.Count > 0) { RotateTime = new TimeRange { Min = (int)_element.RotateList.Min(k => k.StartTime), Max = (int)_element.RotateList.Max(k => k.EndTime), }; Rad.Source = _element.RotateList.First().R1; Rad.Target = _element.RotateList.Last().R2; } if (_element.ScaleList.Count > 0) { VTime = new TimeRange { Min = (int)_element.ScaleList.Min(k => k.StartTime), Max = (int)_element.ScaleList.Max(k => k.EndTime) }; Vx.Source = _element.ScaleList.First().S1 *_vSize.Width; Vy.Source = _element.ScaleList.First().S1 *_vSize.Width; Vx.Target = _element.ScaleList.Last().S2 *_vSize.Height; Vy.Target = _element.ScaleList.Last().S2 *_vSize.Height; } if (_element.VectorList.Count > 0) { if (!VTime.Equals(TimeRange.Default)) { var tmpMin = (int)_element.VectorList.Min(k => k.StartTime); var tmpMax = (int)_element.VectorList.Max(k => k.EndTime); if (tmpMin < VTime.Min) { VTime.Min = tmpMin; Vx.Source = _element.VectorList.First().Vx1 *_vSize.Width; Vy.Source = _element.VectorList.First().Vy1 *_vSize.Height; } if (tmpMax > VTime.Max) { VTime.Max = tmpMax; Vx.Target = _element.VectorList.Last().Vx2 *_vSize.Width; Vy.Target = _element.VectorList.Last().Vy2 *_vSize.Height; } } else { VTime = new TimeRange { Min = (int)_element.VectorList.Min(k => k.StartTime), Max = (int)_element.VectorList.Max(k => k.EndTime) }; Vx.Source = _element.VectorList.First().Vx1 *_vSize.Width; Vy.Source = _element.VectorList.First().Vy1 *_vSize.Height; Vx.Target = _element.VectorList.Last().Vx2 *_vSize.Width; Vy.Target = _element.VectorList.Last().Vy2 *_vSize.Height; } } if (_element.MoveList.Count > 0) { MovTime = new TimeRange { Min = (int)_element.MoveList.Min(k => k.StartTime), Max = (int)_element.MoveList.Max(k => k.EndTime) }; X.Source = (_element.MoveList.First().X1 + 107) * _vSize.Width; Y.Source = _element.MoveList.First().Y1 *_vSize.Height; X.Target = (_element.MoveList.Last().X2 + 107) * _vSize.Width; Y.Target = _element.MoveList.Last().Y2 *_vSize.Height; } if (_element.MoveXList.Count > 0) { if (!MovTime.Equals(TimeRange.Default)) { var tmpMin = (int)_element.MoveXList.Min(k => k.StartTime); var tmpMax = (int)_element.MoveXList.Max(k => k.EndTime); if (tmpMin < MovTime.Min) { MovTime.Min = tmpMin; X.Source = (_element.MoveXList.First().X1 + 107) * _vSize.Width; } if (tmpMax > MovTime.Max) { MovTime.Max = tmpMax; X.Target = (_element.MoveXList.Last().X2 + 107) * _vSize.Width; } } else { MovTime = new TimeRange { Min = (int)_element.MoveXList.Min(k => k.StartTime), Max = (int)_element.MoveXList.Max(k => k.EndTime) }; X.Source = (_element.MoveXList.First().X1 + 107) * _vSize.Width; X.Target = (_element.MoveXList.Last().X2 + 107) * _vSize.Width; } } if (_element.MoveYList.Count > 0) { if (!MovTime.Equals(TimeRange.Default)) { var tmpMin = (int)_element.MoveYList.Min(k => k.StartTime); var tmpMax = (int)_element.MoveYList.Max(k => k.EndTime); if (tmpMin <= MovTime.Min) { MovTime.Min = tmpMin; Y.Source = _element.MoveYList.First().Y1 *_vSize.Height; } if (tmpMax >= MovTime.Max) { MovTime.Max = tmpMax; Y.Target = _element.MoveYList.Last().Y2 *_vSize.Height; } } else { MovTime = new TimeRange { Min = (int)_element.MoveYList.Min(k => k.StartTime), Max = (int)_element.MoveYList.Max(k => k.EndTime) }; Y.Source = _element.MoveYList.First().Y1 *_vSize.Height; Y.Target = _element.MoveYList.Last().Y2 *_vSize.Height; } } if (_element.ColorList.Count > 0) { CTime = new TimeRange { Min = (int)_element.ColorList.Min(k => k.StartTime), Max = (int)_element.ColorList.Max(k => k.EndTime) }; R.Source = _element.ColorList.First().R1; G.Source = _element.ColorList.First().G1; B.Source = _element.ColorList.First().B1; R.Target = _element.ColorList.Last().R2; G.Target = _element.ColorList.Last().G2; B.Target = _element.ColorList.Last().B2; } if (_element.ParameterList.Count > 0) { PTime = new TimeRange { Min = (int)_element.ParameterList.Min(k => k.StartTime), Max = (int)_element.ParameterList.Max(k => k.EndTime) }; } X.RealTimeToSource(); Y.RealTimeToSource(); Rad.RealTimeToSource(); Vx.RealTimeToSource(); Vy.RealTimeToSource(); F.RealTimeToSource(); R.RealTimeToSource(); G.RealTimeToSource(); B.RealTimeToSource(); }
public override string ToString() { return(Vx.ToString() + ", " + Vr.ToString()); }
public override string ToString() { return($"{base.ToString()} AND V[{Vx.ToString(ByteFormat)}], V[{Vy.ToString(ByteFormat)}]"); }
public Velocity GetVelocity() { return(new Velocity(Math.Sqrt(Math.Pow(Vx.GetBasicVal(), 2) + Math.Pow(Vy.GetBasicVal(), 2)), UnitVelocity.Basic).Convert(Settings.Quantities.Units.Velocity)); }