/// <summary> /// Performs intersection-equality testing on two objects /// </summary> /// <param name="continuation">Continuation to operate on</param> /// <param name="expected">Object to test against</param> /// <param name="customEqualityComparers">Objects implementing IEqualityComparer<TProperty> /// for customising equality testing for properties of type TProperty</param> /// <typeparam name="T">Original type</typeparam> public static void Equal <T>( this IIntersection <T> continuation, object expected, params object[] customEqualityComparers ) { continuation.Equal(expected, NULL_STRING, customEqualityComparers); }
/// <summary> /// Performs intersection-equality testing on two objects /// </summary> /// <param name="continuation">Continuation to operate on</param> /// <param name="expected">Object to test against</param> /// <param name="customMessage"></param> /// <param name="customEqualityComparers">Objects implementing IEqualityComparer<TProperty> /// for customising equality testing for properties of type TProperty</param> /// <typeparam name="T">Original type</typeparam> public static void Equal <T>( this IIntersection <T> continuation, object expected, string customMessage, params object[] customEqualityComparers ) { continuation.Equal(expected, () => customMessage, customEqualityComparers); }
public EntityView( IIntersection <ViewIntersectionModel, ViewIntersectionField, EntityModel, EntityField> classToEntityModelIntersection, IIntersection <EntityModel, EntityField, TypeModel, PropertyInfoField> entityToClassIntersection ) { ClassToEntityIntersection = classToEntityModelIntersection; EntityToClassIntersection = entityToClassIntersection; var mappingFactory = new DefaultMappingFactory <EntityModel, EntityField, TypeModel, PropertyInfoField>(); Mapping = mappingFactory.CreateMapping(entityToClassIntersection); }
public void triangle_IntersectsTriPlane_testFalseOK() { var v0 = new Vector3(2, 1, 0); var v1 = new Vector3(4, 2, 0); var v2 = new Vector3(2, 4, 0); var pt = new Vector3(4, 4, 1); var dir = new Vector3(1, 1, 0); var ray = new Ray3(pt, dir); Triangle tri = new Triangle(v0, v1, v2); IIntersection ir = tri.IntersectsTriPlane(ray); Assert.IsFalse(ir.Intersects); }
/// <summary> /// Performs intersection-equality testing on two objects /// </summary> /// <param name="continuation">Continuation to operate on</param> /// <param name="expected">Object to test against</param> /// <param name="customMessageGenerator">Generates a custom message to add to failure messages</param> /// <param name="customEqualityComparers">Objects implementing IEqualityComparer<TProperty> /// for customising equality testing for properties of type TProperty</param> /// <typeparam name="T">Original type</typeparam> public static void Equal <T>( this IIntersection <T> continuation, object expected, Func <string> customMessageGenerator, params object[] customEqualityComparers ) { RunIntersectioEqualityTest( continuation, expected, customMessageGenerator, customEqualityComparers ); }
public void triangle_intersectedByTest_testOK() { IVector3 v0 = new Vector3(2, 1, 0); IVector3 v1 = new Vector3(4, 2, 0); IVector3 v2 = new Vector3(2, 4, 0); IVector3 pt = new Vector3(3, 2, 1); IVector3 dir = new Vector3(0, 0, -1); var ray = new Ray3(pt, dir); Triangle tri = new Triangle(v0, v1, v2); IIntersection ir = tri.IntersectedBy(ray); Assert.IsTrue(ir.Intersects); Assert.AreEqual(3.0, ir.Point.X, .001); Assert.AreEqual(2.0, ir.Point.Y, .001); Assert.AreEqual(0.0, ir.Point.Z, .001); }
public void triangle_IntersectsTriPlane_testOK() { IVector3 v0 = new Vector3(2, 1, 0.5); IVector3 v1 = new Vector3(4, 2, 0.5); IVector3 v2 = new Vector3(2, 4, 0.5); IVector3 pt = new Vector3(4, 4, 1); IVector3 dir = new Vector3(0, 0, -1); var ray = new Ray3(pt, dir); Triangle tri = new Triangle(v0, v1, v2); IIntersection ir = tri.IntersectsTriPlane(ray); Assert.IsTrue(ir.Intersects); Assert.AreEqual(4.0, ir.Point.X, .001); Assert.AreEqual(4.0, ir.Point.Y, .001); Assert.AreEqual(0.5, ir.Point.Z, .001); IIntersection irt = tri.IntersectedBy(ray); Assert.IsFalse(irt.Intersects); }
public IIntersection IntersectedBy(IRay <IVector3> ray) { try { IIntersection pt = IntersectsTriPlane(ray); if (pt.Intersects && Contains(pt.Point)) { pt.Intersects = true; } else { pt.Intersects = false; } return(pt); } catch (Exception) { throw; } }
public List <ITriangle> Split(IRay <IVector3> ray) { try { List <ITriangle> tris = new List <ITriangle>(); IIntersection pt = IntersectedBy(ray); if (pt.Intersects) { tris.Add(new Triangle(vert[0], vert[1], pt.Point, index)); tris.Add(new Triangle(vert[1], vert[2], pt.Point, index)); tris.Add(new Triangle(vert[2], vert[0], pt.Point, index)); } else { tris.Add(this); } return(tris); } catch (Exception) { throw; } }
public static Vector3 GetPosition(this IIntersection intersection) { Ensure.That(intersection, nameof(intersection)).IsNotNull(); return((Vector3)intersection.RawData["position"]); }
public static void Search(SeqTextIR seq, string q, IIntersection<int> ialg) { Console.WriteLine ("Query: '{0}'", q); long itime = DateTime.Now.Ticks; var res = seq.SearchPhrase (q, ialg); int i = 0; int max_len_snippet = 128; foreach (var occ in res) { if (i >= 10) { Console.WriteLine ("Too many results skipping to the end"); break; } i++; string uri; int docid; int sp; int len; string snippet = seq.GetSnippet (occ, max_len_snippet, out uri, out docid, out sp, out len); Console.WriteLine (); Console.WriteLine ("=========== ResultID {0}, occpos: {1}, uri: {2}", i, occ, uri); Console.WriteLine ("=========== Start snippet, snippet len: {0}, docid: {1}, offset_file: {2}", snippet.Length, docid, sp); Console.WriteLine (snippet); Console.WriteLine ("=========== End snippet"); } Console.WriteLine ("Total results: {0}", i); var tspan = TimeSpan.FromTicks (DateTime.Now.Ticks - itime); Console.WriteLine ("query time: {0}", tspan); }
public ComparisonUI(IIntersection<int> alg) { this.ialg = alg; }
protected virtual IEnumerable<int> GetCandidates(IList<IList<int>> posting_lists, IIntersection<int> ialg) { if (posting_lists.Count == 0) { return new int[0]; } else if (posting_lists.Count == 1) { return posting_lists [0]; } else { return ialg.Intersection (posting_lists); } }
public virtual IList<int> SearchPhrase(IList<string> query, IIntersection<int> ialg) { var posting = this.GetPostingLists (query); var _r = this.GetCandidates (posting, ialg); var _s = _r as IList<int>; if (_s == null) { return new List<int> (_r); } return _s; }
private async Task InitGpio(ConfigurationSettings cfg) { try { var gpio = GpioController.GetDefault(); // Show an error if there is no GPIO controller if (gpio == null) { _eventor.SendLogMessage(cfg.IntersectionId, true, "There is no GPIO controller on this device.", DateTime.UtcNow); return; } //Construct the bulbs await BuildBulbs(gpio, cfg); //Construct the Lamps await BuildLamps(cfg); //Put them in sets (only one lamp sets for this case...) _nSet = new BasicLampSet(cfg.NorthLampSetId, new List <ILamp> { _nLamp }, 0, false); _sSet = new BasicLampSet(cfg.SouthLampSetId, new List <ILamp> { _sLamp }, 180, false); _eSet = new BasicLampSet(cfg.EastLampSetId, new List <ILamp> { _eLamp }, 90, true); _wSet = new BasicLampSet(cfg.WestLampSetId, new List <ILamp> { _wLamp }, 270, true); //Establish the lamp sets on traffic routes _nsRoute = new BasicTrafficRoute(cfg.NorthSouthRouteId, 5, false, new List <ILampSet> { _nSet, _sSet }); _nsRoute.TransitionRightOfWay().Wait(); await Task.Delay(1000); _nsRoute.TransitionRightOfWay().Wait(); await Task.Delay(1000); _ewRoute = new BasicTrafficRoute(cfg.EastWestRouteId, 0, true, new List <ILampSet> { _eSet, _wSet }); _ewRoute.TransitionRightOfWay().Wait(); await Task.Delay(1000); _ewRoute.TransitionRightOfWay().Wait(); await Task.Delay(1000); //Put the intersection together _theIntersection = new BasicFourWayIntersection(cfg.IntersectionId, 3, new List <ITrafficRoute> { _nsRoute, _ewRoute }); _eventor.SendLogMessage(cfg.IntersectionId, false, "POST completed.", DateTime.UtcNow); } catch (Exception ex) { _eventor.SendLogMessage(cfg.IntersectionId, true, ex.ToString(), DateTime.UtcNow); throw; } }
public virtual IList<int> SearchPhrase(string query, IIntersection<int> ialg, Action<QueryParser> modify_query = null) { var qparser = new QueryParser (this.InputTokenizer); qparser.Parse (query); if (null != modify_query) { modify_query (qparser); } var posting = this.GetPostingLists (qparser); var _r = this.GetCandidates (qparser, posting, ialg); var _s = _r as IList<int>; if (_s == null) { return new List<int> (_r); } return _s; }
public static Vector3 GetNormal(this IIntersection intersection) { Ensure.That(intersection, nameof(intersection)).IsNotNull(); return((Vector3)intersection.RawData["normal"]); }