// // RightAngle(A, B, C), Angle(A, B, X) + Angle(X, B, C) = 90 -> Complementary(Angle(A, B, X), Angle(X, B, C)) // public static List <EdgeAggregator> InstantiateToComplementary(AngleEquation eq, RightAngle ra, GroundedClause original) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); // // Acquire the two angles from the equation // KeyValuePair <int, int> cards = eq.GetCardinalities(); List <GroundedClause> terms = cards.Key == 2 ? eq.lhs.CollectTerms() : eq.rhs.CollectTerms(); List <GroundedClause> singleton = cards.Key == 1 ? eq.lhs.CollectTerms() : eq.rhs.CollectTerms(); Angle angle1 = terms[0] as Angle; Angle angle2 = terms[1] as Angle; // Create the resultant angle to compare to the input right angle Segment shared = angle1.IsAdjacentTo(angle2); if (!ra.HasSegment(angle1.OtherRayEquates(shared)) || !ra.HasSegment(angle2.OtherRayEquates(shared))) { return(newGrounded); } // Success, we have correspondence Complementary comp = new Complementary(angle1, angle2); List <GroundedClause> antecedent = new List <GroundedClause>(); antecedent.Add(original); newGrounded.Add(new EdgeAggregator(antecedent, comp, annotation)); return(newGrounded); }
public void CanReturn200StatusCode() { DbContextOptions <ColorWheelDbContext> fakeOptions = new DbContextOptionsBuilder <ColorWheelDbContext>() .UseInMemoryDatabase(databaseName: "ColorWheelDbContext") .Options; using (ColorWheelDbContext fakeDB = new ColorWheelDbContext(fakeOptions)) { Color yellow = new Color { ID = 1, ColorName = "Yellow", HexCode = "#FEFE33" }; Color violet = new Color { ID = 7, ColorName = "Violet", HexCode = "#8601AF" }; Complementary complementary = new Complementary(); complementary.ColorOneID = 1; complementary.ColorTwoID = 7; fakeDB.Add(yellow); fakeDB.Add(violet); fakeDB.Add(complementary); fakeDB.SaveChanges(); var color1 = "Yellow"; var color2 = "Violet"; var controller = new ComplementaryController(fakeDB); var actionResult = controller.Get(color1, color2); var okObjectResult = actionResult as OkObjectResult; Assert.IsType <OkObjectResult>(actionResult); } }
public void CanReturn404StatusCode() { DbContextOptions <ColorWheelDbContext> moreFakeOptions = new DbContextOptionsBuilder <ColorWheelDbContext>() .UseInMemoryDatabase(databaseName: "ColorWheelDbContext") .Options; using (ColorWheelDbContext fakeDB = new ColorWheelDbContext(moreFakeOptions)) { Color moreYellow = new Color { ID = 1, ColorName = "Yellow", HexCode = "#FEFE33" }; Color moreYellowOrange = new Color { ID = 12, ColorName = "Yellow-Orange", HexCode = "#FCCC1A" }; Complementary moreComplementary = new Complementary(); moreComplementary.ColorOneID = 1; moreComplementary.ColorTwoID = 2; fakeDB.Add(moreYellow); fakeDB.Add(moreYellowOrange); fakeDB.Add(moreComplementary); fakeDB.SaveChanges(); var moreColor1 = "Yellow"; var moreColor2 = "Red"; var moreController = new ComplementaryController(fakeDB); var moreActionResult = moreController.Get(moreColor1, moreColor2); var notFoundResult = moreActionResult as NotFoundResult; Assert.IsType <NotFoundResult>(moreActionResult); } }
public override global::System.Data.DataSet Clone() { Complementary cln = ((Complementary)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public void CanGetIDforComplementary2() { Complementary complementary = new Complementary(); complementary.ColorOneID = 6; complementary.ColorTwoID = 12; Assert.Equal(6, complementary.ColorOneID); Assert.Equal(12, complementary.ColorTwoID); }
public void CanGetIDforComplementary3() { Complementary complementary = new Complementary(); complementary.ColorOneID = 11; complementary.ColorTwoID = 5; Assert.Equal(11, complementary.ColorOneID); Assert.Equal(5, complementary.ColorTwoID); }
public void CanGetIDforComplementary1() { Complementary complementary = new Complementary(); complementary.ColorOneID = 1; complementary.ColorTwoID = 7; Assert.Equal(1, complementary.ColorOneID); Assert.Equal(7, complementary.ColorTwoID); }
public static void CustomOperatorOnesComplement(bool useInterpreter) { Complementary value = new Complementary { Value = 43 }; Expression <Func <Complementary> > lambda = Expression.Lambda <Func <Complementary> >( Expression.OnesComplement(Expression.Constant(value))); Func <Complementary> func = lambda.Compile(useInterpreter); Assert.Equal(~43, func().Value); }
public static void ExplicitOperatorOnesComplement(bool useInterpreter) { Complementary value = new Complementary { Value = 43 }; MethodInfo method = typeof(Complementary).GetMethod(nameof(Complementary.OnesComplement)); Expression <Func <Complementary> > lambda = Expression.Lambda <Func <Complementary> >( Expression.OnesComplement(Expression.Constant(value), method)); Func <Complementary> func = lambda.Compile(useInterpreter); Assert.Equal(~43, func().Value); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { Complementary ds = new Complementary(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
// // Complementary(Angle(A, B, C), Angle(D, E, F)) -> Angle(A, B, C) + Angle(D, E, F) = 90 // public static List <EdgeAggregator> InstantiateFromComplementary(Complementary comp) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); List <GroundedClause> antecedent = new List <GroundedClause>(); antecedent.Add(comp); GeometricAngleEquation angEq = new GeometricAngleEquation(new Addition(comp.angle1, comp.angle2), new NumericValue(90)); newGrounded.Add(new EdgeAggregator(antecedent, angEq, annotation)); return(newGrounded); }
// // We know at this point that we have a right triangle // private static List <EdgeAggregator> InstantiateRightTriangle(Triangle tri, GroundedClause original) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); KeyValuePair <Angle, Angle> acuteAngles = tri.GetAcuteAngles(); Complementary newComp = new Complementary(acuteAngles.Key, acuteAngles.Value); // Hypergraph List <GroundedClause> antecedent = Utilities.MakeList <GroundedClause>(original); newGrounded.Add(new EdgeAggregator(antecedent, newComp, annotation)); return(newGrounded); }
private static List <EdgeAggregator> CheckAndGeneratePerpendicularImplyCongruentAdjacent(Perpendicular perp, Angle angle1, Angle angle2) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); if (!Utilities.CompareValues(angle1.measure + angle2.measure, 90)) { return(newGrounded); } // The perpendicular intersection must occur at the same vertex of both angles (we only need check one). if (!(angle1.GetVertex().Equals(perp.intersect) && angle2.GetVertex().Equals(perp.intersect))) { return(newGrounded); } // Are the angles adjacent? Segment sharedRay = angle1.IsAdjacentTo(angle2); if (sharedRay == null) { return(newGrounded); } // Do the non-shared rays for both angles align with the segments defined by the perpendicular intersection? if (!perp.DefinesBothRays(angle1.OtherRayEquates(sharedRay), angle2.OtherRayEquates(sharedRay))) { return(newGrounded); } // // Now we have perpendicular -> complementary angles scenario // Complementary cas = new Complementary(angle1, angle2); // Construct hyperedge List <GroundedClause> antecedent = new List <GroundedClause>(); antecedent.Add(perp); antecedent.Add(angle1); antecedent.Add(angle2); newGrounded.Add(new EdgeAggregator(antecedent, cas, annotation)); return(newGrounded); }
public IActionResult Get(string id) { Color color = _context.Colors.FirstOrDefault(c => c.ColorName == id); Complementary complimentary = _context.Complementary.FirstOrDefault(a => a.ColorOneID == color.ID || a.ColorTwoID == color.ID); if (color == null || complimentary == null) { return(NotFound()); } Color color1 = _context.Colors.FirstOrDefault(c => c.ID == complimentary.ColorOneID); Color color2 = _context.Colors.FirstOrDefault(c => c.ID == complimentary.ColorTwoID); List <Color> palette = new List <Color> { color1, color2 }; return(Ok(new { palette })); }
public void Complementary_Match() { var hsv = new HSV(213, 46, 49); var algorithm = new Complementary(); var actual = algorithm.Match(hsv); var expected = new Blend() { Colors = new[] { new HSV(213, 46, 49), new HSV(213, 92, 73.5), new HSV(47, 46, 49), new HSV(47, 92, 73.5), new HSV(0, 0, 49), new HSV(0, 0, 51) } }; Assert.Equal(expected, actual, new BlendEqualityComparer()); }
public void ComplementaryController3() { DbContextOptions <ColorWheelDbContext> options6 = new DbContextOptionsBuilder <ColorWheelDbContext>() .UseInMemoryDatabase(databaseName: "ColorWheelDbContext") .Options; using (ColorWheelDbContext dbContext6 = new ColorWheelDbContext(options6)) { Color color = new Color(); color.ColorName = "Orange"; Complementary complementary = new Complementary(); complementary.ColorOneID = 1; complementary.ColorTwoID = 4; dbContext6.Add(color); dbContext6.Add(complementary); dbContext6.SaveChanges(); var expected = "Orange"; var controller = new ComplementaryController(dbContext6); var actionResult = controller.Get(expected); var okObjectResult = actionResult as OkObjectResult; Assert.IsType <OkObjectResult>(actionResult); } }
public IActionResult Get(string id1, string id2) { Color color1 = _context.Colors.FirstOrDefault(c => c.ColorName == id1); Color color2 = _context.Colors.FirstOrDefault(c => c.ColorName == id2); if (color1 == null || color2 == null) { return(NotFound()); } Complementary palette = new Complementary(); palette.ColorOneID = color1.ID; palette.ColorTwoID = color2.ID; Complementary complementary = _context.Complementary.FirstOrDefault(a => a.ColorOneID == palette.ColorOneID); if (palette.ColorOneID == complementary.ColorOneID && palette.ColorTwoID == complementary.ColorTwoID) { return(Ok(true)); } return(Ok(false)); }
public static Complementary OnesComplement(Complementary c) => new Complementary { Value = ~c.Value };
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); Complementary ds = new Complementary(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "ComplementaryDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
private static List <EdgeAggregator> IndirectRelations(CongruentAngles cas, AnglePairRelation relation1, AnglePairRelation relation2) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); // Do we have the same type of relation? if (relation1.GetType() != relation2.GetType()) { return(newGrounded); } // // Determine the shared values amongst the relations // Angle shared1 = relation1.AngleShared(cas); if (shared1 == null) { return(newGrounded); } Angle shared2 = cas.OtherAngle(shared1); if (!relation2.HasAngle(shared2)) { return(newGrounded); } Angle otherAngle1 = relation1.OtherAngle(shared1); Angle otherAngle2 = relation2.OtherAngle(shared2); // Avoid generating a reflexive relationship if (otherAngle1.Equates(otherAngle2)) { return(newGrounded); } // // Congruent(Angle(1), Angle(3)) // // The other two angles from the relation pairs are then congruent GeometricCongruentAngles gcas = new GeometricCongruentAngles(otherAngle1, otherAngle2); // Avoid direct cyclic congruent angle generation if (cas.StructurallyEquals(gcas)) { return(newGrounded); } // Construct hyperedge List <GroundedClause> antecedent = new List <GroundedClause>(); antecedent.Add(cas); antecedent.Add(relation1); antecedent.Add(relation2); // // AnglePairRelation(Angle(1), Angle(4)), // AnglePairRelation(Angle(2), Angle(3)), // if (relation1 is Complementary && relation2 is Complementary) { Complementary comp1 = new Complementary(shared1, otherAngle2); Complementary comp2 = new Complementary(shared2, otherAngle1); newGrounded.Add(new EdgeAggregator(antecedent, comp1, compAnnotation)); newGrounded.Add(new EdgeAggregator(antecedent, comp2, compAnnotation)); } else if (relation1 is Supplementary && relation2 is Supplementary) { Supplementary supp1 = new Supplementary(shared1, otherAngle2); Supplementary supp2 = new Supplementary(shared2, otherAngle1); newGrounded.Add(new EdgeAggregator(antecedent, supp1, suppAnnotation)); newGrounded.Add(new EdgeAggregator(antecedent, supp2, suppAnnotation)); } else { throw new ArgumentException("RelationsOfCongruent:: Expected a supplementary or complementary angle, not " + relation1.GetType()); } newGrounded.Add(new EdgeAggregator(antecedent, gcas, relation1 is Complementary ? compAnnotation : suppAnnotation)); return(newGrounded); }