public void T05_TestPattern() { if (Scene.current != null) { Scene.current.Clear(); } Pattern pattern = new TestPattern(); Assert.AreEqual(new Mat4(), pattern.matrix); pattern.matrix = Mat4.TranslateMatrix(1, 2, 3); Assert.AreEqual(Mat4.TranslateMatrix(1, 2, 3), pattern.matrix); Sphere sphere = new Sphere(); sphere.SetMatrix(Mat4.ScaleMatrix(2, 2, 2)); sphere.material.pattern = new TestPattern(); Color c = sphere.material.pattern.PatternAtObject(sphere, new Point(2, 3, 4)); Assert.AreEqual(new Color(1, 1.5, 2), c); sphere.SetMatrix(new Mat4()); sphere.material.pattern.matrix = Mat4.ScaleMatrix(2, 2, 2); c = sphere.material.pattern.PatternAtObject(sphere, new Point(2, 3, 4)); Assert.AreEqual(new Color(1, 1.5, 2), c); sphere.SetMatrix(Mat4.ScaleMatrix(2, 2, 2)); sphere.material.pattern.matrix = Mat4.TranslateMatrix(0.5, 1, 1.5); c = sphere.material.pattern.PatternAtObject(sphere, new Point(2.5, 3, 3.5)); Assert.AreEqual(new Color(0.75, 0.5, 0.25), c); }
public void TestPatternAssignTransform() { TestPattern pattern = new TestPattern(); pattern.Transform = new Translate(1, 2, 3).GetTransform(); Assert.AreEqual(pattern.Transform, new Translate(1, 2, 3).GetTransform()); }
public void ColorOnShapeAt_should_use_both_the_shape_and_pattern_transformation() { var shape = new Sphere(transform: Matrix4x4.CreateScaling(2, 2, 2)); var pattern = new TestPattern(Matrix4x4.CreateTranslation(0.5, 1, 1.5)); Color color = pattern.ColorOnShapeAt(shape, new Point(2.5, 3, 3.5)); color.Should().Be(new Color(0.75, 0.5, 0.25)); }
public void TestPatternWithPatternTransform() { var sphere = new Sphere(); var pattern = new TestPattern(); pattern.Transform = Matrix.Scaling(2, 2, 2); var c = pattern.PatternAtShape(sphere, new Point(2, 3, 4)); Assert.AreEqual(new Colour(1, 1.5, 2), c); }
public void ColorOnShapeAt_should_use_the_pattern_transformation() { var shape = new Sphere(); var pattern = new TestPattern(Matrix4x4.CreateScaling(2, 2, 2)); Color color = pattern.ColorOnShapeAt(shape, new Point(2, 3, 4)); color.Should().Be(new Color(1, 1.5, 2)); }
///------------------------------------------------------------------------------------------------- /// <summary> Tests if this Pattern is considered equal to another. </summary> /// /// <remarks> Kemp, 1/18/2019. </remarks> /// /// <param name="m"> The pattern to compare to this object. </param> /// /// <returns> True if the objects are considered equal, false if they are not. </returns> ///------------------------------------------------------------------------------------------------- public override bool Equals(Pattern m) { if (m is TestPattern) { TestPattern c = (TestPattern)m; return(xform.Equals(c.xform)); } return(false); }
public void AssigningTransformation() { var pattern = new TestPattern { Transform = tf.Translation(1, 2, 3) }; Assert.Equal(tf.Translation(1, 2, 3), pattern.Transform); }
public void TestPatternWithObjectAndPatternTransform() { var sphere = new Sphere(); sphere.Transform = Matrix.Scaling(2, 2, 2); var pattern = new TestPattern(); pattern.Transform = Matrix.Translation(0.5, 1, 1.5); var c = pattern.PatternAtShape(sphere, new Point(2.5, 3, 3.5)); Assert.AreEqual(new Colour(0.75, 0.5, 0.25), c); }
public void PatternWithTransformationObject() { var s = new shapes.Sphere(tf.Scaling(2, 2, 2)); var pattern = new TestPattern(); var c = pattern.AtObject(s, pt.Point(2, 3, 4)); Assert.Equal(new RTF.Color(1, 1.5, 2), c); }
public void APatternWithAnObjectTransformationTest() { var shape = Helper.Sphere(); shape.Transform = Helper.Scaling(2, 2, 2); var pattern = new TestPattern(); var c = pattern.GetColorAtShape(shape, Helper.CreatePoint(2, 3, 4)); Check.That(c).IsEqualTo(new Color(1, 1.5, 2)); }
public void PatternAtShapePAtternTransform() { Sphere shape = new Sphere(); TestPattern pattern = new TestPattern(); pattern.Transform = new Scale(2, 2, 2).GetTransform(); Color c = pattern.PatternAtShape(shape, Tuple.Point(2, 3, 4)); Assert.AreEqual(c, new Color(1, 1.5, 2)); }
public void APatternWithBothAnObjectAndAPatternTransformation() { var shape = Helper.Sphere(); shape.Transform = Helper.Scaling(2, 2, 2); var pattern = new TestPattern(); pattern.Transform = Helper.Translation(0.5, 1, 1.5); var c = pattern.GetColorAtShape(shape, Helper.CreatePoint(2.5, 3, 3.5)); Check.That(c).IsEqualTo(new Color(0.75, 0.5, 0.25)); }
public void PatternWithTransformationObjectAndPattern() { var s = new shapes.Sphere(tf.Scaling(2, 2, 2)); var pattern = new TestPattern() { Transform = tf.Translation(0.5, 1, 1.5) }; var c = pattern.AtObject(s, pt.Point(2.5, 3, 3.5)); Assert.Equal(new RTF.Color(0.75, 0.5, 0.25), c); }
public void PatternAtShapeBothTransform() { Sphere shape = new Sphere(); shape.Transform = new Scale(2, 2, 2).GetTransform(); TestPattern pattern = new TestPattern(); pattern.Transform = new Translate(0.5, 1, 1.5).GetTransform(); Color c = pattern.PatternAtShape(shape, Tuple.Point(2.5, 3, 3.5)); Assert.AreEqual(c, new Color(0.75, 0.5, 0.25)); }
public void PatternPatternTransform() { Sphere s = new Sphere(); TestPattern pattern = new TestPattern(); pattern.Transform = Matrix4.ScaleMatrix(2, 2, 2); Color c = pattern.PatternAtObject(s, new Point(2, 3, 4)); Color answer = new Color(1, 1.5f, 2); Assert.True(c == answer); }
private static void Test(TestPattern testPattern, int times, int averaging, bool ignoreFirst) { if (ignoreFirst) { foreach (var action in testPattern.Actions) { action(); } } long firstTime = -1; foreach (var action in testPattern.Actions) { //GC.Collect(); //GC.WaitForPendingFinalizers(); long totalTime = 0; for (int avg = 0; avg < averaging; avg++) { Console.Write("Test"); Console.Write(avg + 1); var sw = Stopwatch.StartNew(); for (int i = 0; i < times; i++) { action(); } sw.Stop(); totalTime += sw.Elapsed.Ticks; Console.CursorLeft = 0; } if (firstTime < 0) { firstTime = totalTime; } Console.WriteLine( "{0,25} {1:#,0.000}[ms/test] {2:0.000000000}[ns/call] {3:0.000%}", testPattern.Name, new TimeSpan(totalTime / averaging).TotalMilliseconds, new TimeSpan(totalTime / averaging).TotalMilliseconds * 1000 / times, (totalTime / (double)firstTime)); } }
public void PatternObjectPatternTransform() { Sphere s = new Sphere(); s.Transform = Matrix4.ScaleMatrix(2, 2, 2); TestPattern pattern = new TestPattern(); pattern.Transform = Matrix4.TranslateMatrix(0.5f, 1, 1.5f); Color c = pattern.PatternAtObject(s, new Point(2.5f, 3, 3.5f)); Color answer = new Color(0.75f, 0.5f, 0.25f); Assert.True(c == answer); }
public TestPresentationImage() : base(TestPattern.CreateRGBKCorners(new Size(_width, _height))) { DicomFile dcf = new DicomFile(); dcf.DataSet[DicomTags.StudyInstanceUid].SetStringValue("1"); dcf.DataSet[DicomTags.SeriesInstanceUid].SetStringValue("2"); dcf.DataSet[DicomTags.SopInstanceUid].SetStringValue("3"); dcf.DataSet[DicomTags.SopClassUid].SetStringValue(SopClass.SecondaryCaptureImageStorageUid); dcf.DataSet[DicomTags.InstanceNumber].SetStringValue("1"); dcf.DataSet[DicomTags.NumberOfFrames].SetStringValue("1"); dcf.MetaInfo[DicomTags.TransferSyntaxUid].SetStringValue(TransferSyntax.ImplicitVrLittleEndianUid); dcf.MetaInfo[DicomTags.MediaStorageSopClassUid].SetStringValue(SopClass.SecondaryCaptureImageStorageUid); dcf.MetaInfo[DicomTags.MediaStorageSopInstanceUid].SetStringValue("3"); _imageSop = new ImageSop(new TestDataSource(dcf)); }
private void getTestPatternSettingsButton_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(comboBoxDisplaySystemIds.Text)) { MessageBox.Show("Please enter a display system Id."); return; } int displaySystemId = Int32.Parse(comboBoxDisplaySystemIds.Text); //Call JSON rpc post request with source value JObject result; try { result = SendGetRequest(Common.CreateJsonRequest("gettestpatternsettings", "{\"displaySystemId\":" + displaySystemId + "}")); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } TestPattern testPatternSettings = JsonConvert.DeserializeObject <TestPattern>(result["result"].ToString()); supportedTestPatternsComboBox.Items.Clear(); testPatternSettings.AvailableTestPatterns.ForEach(x => supportedTestPatternsComboBox.Items.Add(x)); testPatternDirectionsComboBox.Items.Clear(); testPatternSettings.ValidDirections.ForEach(x => testPatternDirectionsComboBox.Items.Add(x)); supportedTestPatternsComboBox.Text = testPatternSettings.SelectedTestPattern; redTextBox.Text = testPatternSettings.Red.ToString(); greenTextBox.Text = testPatternSettings.Green.ToString(); blueTextBox.Text = testPatternSettings.Blue.ToString(); movementCheckBox.Checked = testPatternSettings.Movement; testPatternDirectionsComboBox.Text = testPatternSettings.Direction; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public TestPatternItem(TestPattern type, string name, string pattern) { Type = type; Name = name; Pattern = pattern; }
///------------------------------------------------------------------------------------------------- /// <summary> Main entry-point for this application. </summary> /// /// <remarks> Kemp, 1/18/2019. </remarks> /// /// <param name="args"> An array of command-line argument strings. </param> ///------------------------------------------------------------------------------------------------- static void Main(string[] args) { World defaultWorld = new World(); defaultWorld.AddLight(new LightPoint(new Point(-10, 10, -10), new Color(1, 1, 1))); Sphere s1 = new Sphere(); s1.Material = new Material(); s1.Material.Color = new Color(0.8, 1.0, 0.6); s1.Material.Diffuse = new Color(0.7, 0.7, 0.7); s1.Material.Specular = new Color(0.2, 0.2, 0.2); Sphere s2 = new Sphere(); s2.Transform = MatrixOps.CreateScalingTransform(0.5, 0.5, 0.5); defaultWorld.AddObject(s1); defaultWorld.AddObject(s2); Color white = new Color(1, 1, 1); Color black = new Color(0, 0, 0); Sphere s = new Sphere(); { Material m = new Material(); m.Pattern = new StripePattern(white, black); m.Ambient = new Color(1, 1, 1); m.Diffuse = new Color(0, 0, 0); m.Specular = new Color(0, 0, 0); m.Shininess = 0; RayTracerLib.Vector eyev = new RayTracerLib.Vector(0, 0, -1); RayTracerLib.Vector normalv = new RayTracerLib.Vector(0, 0, -1); Point p1 = new Point(0.9, 0, 0); Point p2 = new Point(1.1, 0, 0); LightPoint light = new LightPoint(new Point(0, 0, -10), new Color(1, 1, 1)); Color c1 = Ops.Lighting(m, s, light, p1, eyev, normalv, false); Color c2 = Ops.Lighting(m, s, light, p2, eyev, normalv, false); bool foo1 = (c1.Equals(white)); bool foo2 = (c2.Equals(black)); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~"); } //public void PatternWithObjectTransformation() { Shape shape = new Sphere() { Transform = MatrixOps.CreateScalingTransform(2, 2, 2) }; Pattern pattern = new TestPattern { Transform = MatrixOps.CreateTranslationTransform(0.5, 1, 1.5) }; Color c = pattern.PatternAtObject(shape, new Point(2.5, 3, 3.5)); bool foo1 = (c.Equals(new Color(0.75, 0.5, 0.25))); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~"); } //public void GradientInterpolates() { Pattern pattern = new GradientPattern(black, white); bool foo1 = (pattern.PatternAt(new Point(0, 0, 0)).Equals(black)); bool foo2 = (pattern.PatternAt(new Point(0.25, 0, 0)).Equals(new Color(0.25, 0.25, 0.25))); bool foo3 = (pattern.PatternAt(new Point(0.5, 0, 0)).Equals(new Color(0.5, 0.5, 0.5))); bool foo4 = (pattern.PatternAt(new Point(0.75, 0, 0)).Equals(new Color(0.75, 0.75, 0.75))); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~"); } { Pattern pattern = new CheckedPattern(black, white); bool foo1 = (pattern.PatternAt(new Point(0, 0, 0)).Equals(black)); bool foo2 = (pattern.PatternAt(new Point(0.99, 0, 0)).Equals(black)); bool foo3 = (pattern.PatternAt(new Point(1.01, 0, 0)).Equals(white)); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~"); } Console.Write("Press Enter to finish ... "); Console.Read(); }
private void setTestPatternSettingsButton_Click(object sender, EventArgs e) { try { TestPattern testPatternSettings = new TestPattern(); testPatternSettings.Direction = testPatternDirectionsComboBox.Text; testPatternSettings.Movement = movementCheckBox.Checked; testPatternSettings.Red = Int32.Parse(redTextBox.Text); testPatternSettings.Green = Int32.Parse(greenTextBox.Text); testPatternSettings.Blue = Int32.Parse(blueTextBox.Text); testPatternSettings.SelectedTestPattern = supportedTestPatternsComboBox.Text; //first check list view if (displaySystemIdsListView.SelectedItems.Count > 0) { var isAllChosen = displaySystemIdsListView.SelectedItems[0].Text.Equals("All"); if (isAllChosen) { string parameters = "{\"pattern\": \"" + supportedTestPatternsComboBox.Text + "\"," + "\"direction\": \"" + testPatternDirectionsComboBox.Text + "\"," + "\"movement\": \"" + movementCheckBox.Checked + "\"," + "\"red\": " + redTextBox.Text + "," + "\"green\": " + greenTextBox.Text + "," + "\"blue\": " + blueTextBox.Text + "}"; //Call JSON rpc post request with source value byte[] data2 = Encoding.ASCII.GetBytes(Common.CreateJsonRequest("settestpatternsettings", parameters)); SendRequest(data2); } else { string displaySystemIds = "["; foreach (ListViewItem displaysystemIdListViewItem in displaySystemIdsListView.SelectedItems) { displaySystemIds += displaysystemIdListViewItem.Text + ","; } displaySystemIds = displaySystemIds.TrimEnd(','); displaySystemIds += "]"; string parameters = "{\"displaySystemIds\":" + displaySystemIds + ", \"pattern\": \"" + supportedTestPatternsComboBox.Text + "\"," + "\"direction\": \"" + testPatternDirectionsComboBox.Text + "\"," + "\"movement\": \"" + movementCheckBox.Checked + "\"," + "\"red\": " + redTextBox.Text + "," + "\"green\": " + greenTextBox.Text + "," + "\"blue\": " + blueTextBox.Text + "}"; //Call JSON rpc post request with source value byte[] data2 = Encoding.ASCII.GetBytes(Common.CreateJsonRequest("settestpatternsettings", parameters)); SendRequest(data2); } } else { if (string.IsNullOrEmpty(comboBoxDisplaySystemIds.Text)) { MessageBox.Show("Please enter a display system Id."); return; } int displaySystemId = Int32.Parse(comboBoxDisplaySystemIds.Text); string parameters = "{\"displaySystemIds\":" + displaySystemId + ", \"pattern\": \"" + supportedTestPatternsComboBox.Text + "\"," + "\"direction\": \"" + testPatternDirectionsComboBox.Text + "\"," + "\"movement\": \"" + movementCheckBox.Checked + "\"," + "\"red\": " + redTextBox.Text + "," + "\"green\": " + greenTextBox.Text + "," + "\"blue\": " + blueTextBox.Text + "}"; //Call JSON rpc post request with source value byte[] data = Encoding.ASCII.GetBytes(Common.CreateJsonRequest("settestpatternsettings", parameters)); SendRequest(data); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void TestPatternDefaultTransform() { var testPattern = new TestPattern(); Assert.AreEqual(Matrix.IdentityMatrix, testPattern.Transform); }
public void TestPatternAssignTransform() { var testPattern = new TestPattern {Transform = Matrix.Translation(1, 2, 3)}; Assert.AreEqual(Matrix.Translation(1,2,3), testPattern.Transform); }
public void Ctor_should_default_the_transformation_matrix_to_the_identity_matrix() { var pattern = new TestPattern(); pattern.Transform.Should().Be(Matrix4x4.Identity); }
public void Given_test_pattern(string id) { patterns[id] = new TestPattern(); }
public void TestPatternDefaultTransform() { TestPattern pattern = new TestPattern(); Assert.AreEqual(pattern.Transform, Matrix.GetIdentityMatrix()); }
public void TheDefaultPatternTransformation() { var pattern = new TestPattern(); Assert.Equal(RTF.Matrix.GetIdentity(), pattern.Transform); }
public void Ctor_should_store_the_transformation_matrix() { var pattern = new TestPattern(Matrix4x4.CreateTranslation(1, 2, 3)); pattern.Transform.Should().Be(Matrix4x4.CreateTranslation(1, 2, 3)); }