public SVector(SVector other) : this(yarpPINVOKE.new_SVector__SWIG_1(SVector.getCPtr(other)), true) { if (yarpPINVOKE.SWIGPendingException.Pending) { throw yarpPINVOKE.SWIGPendingException.Retrieve(); } }
public Collision(Segment s1, Segment s2, Point point) { S1 = s1; S2 = s2; Point = point; var segment = new Segment(S1.P1, Point); DistanceToInitialS1 = segment.Distance; var refractionVector = new SVector(S1.P2.X - Point.X, S1.P2.Y - Point.Y); // vertical case if (s2.P1.X == s2.P2.X) { refractionVector.X = -refractionVector.X; } else { refractionVector.Y = -refractionVector.Y; } ReflectedPosition = new Point(point.X + refractionVector.X, point.Y + refractionVector.Y); var reflectionSegment = new Segment(Point, ReflectedPosition); ReflectionAngle = reflectionSegment.Angle; }
public SVectorEnumerator(SVector collection) { collectionRef = collection; currentIndex = -1; currentObject = null; currentSize = collectionRef.Count; }
public void AddRange(SVector values) { yarpPINVOKE.SVector_AddRange(swigCPtr, SVector.getCPtr(values)); if (yarpPINVOKE.SWIGPendingException.Pending) { throw yarpPINVOKE.SWIGPendingException.Retrieve(); } }
public void SetRange(int index, SVector values) { yarpPINVOKE.SVector_SetRange(swigCPtr, index, SVector.getCPtr(values)); if (yarpPINVOKE.SWIGPendingException.Pending) { throw yarpPINVOKE.SWIGPendingException.Retrieve(); } }
public AliveData(string _key_name, int _health, string _character_name, SVector _position, SVector _euler) { keyName = _key_name; health = _health; characterName = _character_name; position = _position; euler = _euler; }
public static bool LineSegementsIntersect(SVector p, SVector p2, SVector q, SVector q2, out SVector intersection, bool considerCollinearOverlapAsIntersect = false) { intersection = new SVector(); var r = p2 - p; var s = q2 - q; var rxs = r.Cross(s); var qpxr = (q - p).Cross(r); // If r x s = 0 and (q - p) x r = 0, then the two lines are collinear. if (rxs.IsZero() && qpxr.IsZero()) { // 1. If either 0 <= (q - p) * r <= r * r or 0 <= (p - q) * s <= * s // then the two lines are overlapping, if (considerCollinearOverlapAsIntersect) { if ((0 <= (q - p) * r && (q - p) * r <= r * r) || (0 <= (p - q) * s && (p - q) * s <= s * s)) { return(true); } } // 2. If neither 0 <= (q - p) * r = r * r nor 0 <= (p - q) * s <= s * s // then the two lines are collinear but disjoint. // No need to implement this expression, as it follows from the expression above. return(false); } // 3. If r x s = 0 and (q - p) x r != 0, then the two lines are parallel and non-intersecting. if (rxs.IsZero() && !qpxr.IsZero()) { return(false); } // t = (q - p) x s / (r x s) var t = (q - p).Cross(s) / rxs; // u = (q - p) x r / (r x s) var u = (q - p).Cross(r) / rxs; // 4. If r x s != 0 and 0 <= t <= 1 and 0 <= u <= 1 // the two line segments meet at the point p + t r = q + u s. if (!rxs.IsZero() && (0 <= t && t <= 1) && (0 <= u && u <= 1)) { // We can calculate the intersection point using either t or u. intersection = p + t * r; // An intersection was found. return(true); } // 5. Otherwise, the two line segments are not parallel but do not intersect. return(false); }
static void Main(string[] args) { Network.init(); Console.WriteLine("----------------------------------"); Console.WriteLine("Convergence Divergence Zone Module"); Console.WriteLine("----------------------------------"); ResourceFinder rf = new ResourceFinder(); rf.setDefaultContext("MMCM/conf"); //Workaround the "--from" issue bool loadingFromWeights = false; string configFile = "defaultMap.ini"; for (int i = 0; i < args.Count(); i++) { if (args[i] == "--from") { configFile = args[i + 1]; } if (args[i] == "--load") { loadingFromWeights = true; configFile = args[i + 1]; } } if (!loadingFromWeights) { rf.setDefaultConfigFile(configFile); } SVector argsVect = new SVector(args); rf.configure("MMCM_ROOT", argsVect); IConvergenceZone cvz = null; if (loadingFromWeights) { Console.Write("Loading MMCM from weights file..."); string path = rf.findFile(configFile).c_str(); Console.WriteLine(path); cvz = CVZFactory.Create(path); } else { cvz = CVZFactory.Create(rf); } Application.EnableVisualStyles(); MMCM_ControlPanel form = new MMCM_ControlPanel(cvz as CVZ_MMCM); Application.Run(form); }
static void Main(string[] args) { Network.init(); ResourceFinder rf = new ResourceFinder(); bool loadingFromWeights = false; string configFile = "defaultMap.ini"; for (int i = 0; i < args.Count(); i++) { if (args[i] == "--from") { configFile = args[i + 1]; } if (args[i] == "--load") { loadingFromWeights = true; configFile = args[i + 1]; } } if (!loadingFromWeights) { rf.setDefaultConfigFile(configFile); } rf.setDefaultContext("MMCM/conf"); SVector argsVect = new SVector(args); rf.configure("MMCM_ROOT", argsVect); string mapType = CVZFactory.GetCvzType(rf); switch (mapType) { case "MMCM": { RFModuleMMCM module = new RFModuleMMCM(); module.configure(rf); module.runModule(); break; } case "CTPC": { RFModuleCTPC module = new RFModuleCTPC(); module.configure(rf); module.runModule(); break; } default: throw new Exception("Unknown CVZ type"); } }
public SVector GetRange(int index, int count) { global::System.IntPtr cPtr = yarpPINVOKE.SVector_GetRange(swigCPtr, index, count); SVector ret = (cPtr == global::System.IntPtr.Zero) ? null : new SVector(cPtr, true); if (yarpPINVOKE.SWIGPendingException.Pending) { throw yarpPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static SVector Repeat(string value, int count) { global::System.IntPtr cPtr = yarpPINVOKE.SVector_Repeat(value, count); SVector ret = (cPtr == global::System.IntPtr.Zero) ? null : new SVector(cPtr, true); if (yarpPINVOKE.SWIGPendingException.Pending) { throw yarpPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static bool GetCollisionPoint(Segment s1, Segment s2, out Collision collision) { collision = null; var v1 = new SVector(s1.P1.X, s1.P1.Y); var v2 = new SVector(s1.P2.X, s1.P2.Y); var v3 = new SVector(s2.P1.X, s2.P1.Y); var v4 = new SVector(s2.P2.X, s2.P2.Y); if (SegmentHelper.LineSegementsIntersect(v1, v2, v3, v4, out var collisionPoint)) { var collisionPos = new Point(collisionPoint.X, collisionPoint.Y); collision = new Collision(s1, s2, collisionPos); return(true); } return(false); }
public void Set(SVector Obj_) { Pos.Set(Obj_.Pos); Dir.Set(Obj_.Dir); }
private void HandleCollisionWithBlock(IPhysicalView physicalView, SVector intersectionVector) { }
/// <summary> /// Could be done at the same time as objects collisions, /// A wall could be an object with a resistance force emited on impact /// </summary> private void DetectWallColisions() { foreach (var physicalView in _physicalViews) { foreach (var collisionPoint in physicalView.CollisionPoints) { var cornerX = physicalView.RealX + collisionPoint.X; var cornerY = physicalView.RealY + collisionPoint.Y; var blockX = (int)Math.Round(cornerX / _blockSize); var blockY = (int)Math.Round(cornerY / _blockSize); var block = _mapData.GetBlockByCoordinates(blockX, blockY); if (block != null) { var previousCornerX = cornerX - physicalView.V.X; var previousCornerY = cornerY - physicalView.V.Y; var finalCornerVector = new SVector(cornerX, cornerY); var previousVectorCornerVector = new SVector(previousCornerX, previousCornerY); var topLeftVector = new SVector((blockX - 0.5) * _blockSize, (blockY - 0.5) * _blockSize); var topRightVector = new SVector((blockX + 0.5) * _blockSize, (blockY - 0.5) * _blockSize); var bottomRightVector = new SVector((blockX + 0.5) * _blockSize, (blockY + 0.5) * _blockSize); var bottomLeftVector = new SVector((blockX - 0.5) * _blockSize, (blockY + 0.5) * _blockSize); SVector intersectionVector; if (SegmentHelper.LineSegementsIntersect(previousVectorCornerVector, finalCornerVector, topLeftVector, topRightVector, out intersectionVector)) { _logger.Log($"intersection ! {intersectionVector.X} | {intersectionVector.Y}"); HandleCollisionWithBlock(physicalView, intersectionVector); physicalView.V.Y = -physicalView.V.Y; physicalView.RealX += (float)(finalCornerVector.X - intersectionVector.X); physicalView.RealY += (float)(finalCornerVector.Y - intersectionVector.Y); } else if (SegmentHelper.LineSegementsIntersect(previousVectorCornerVector, finalCornerVector, topRightVector, bottomRightVector, out intersectionVector)) { _logger.Log($"intersection ! {intersectionVector.X} | {intersectionVector.Y}"); HandleCollisionWithBlock(physicalView, intersectionVector); physicalView.V.X = -physicalView.V.X; physicalView.RealX += (float)(finalCornerVector.X - intersectionVector.X); physicalView.RealY += (float)(finalCornerVector.Y - intersectionVector.Y); } else if (SegmentHelper.LineSegementsIntersect(previousVectorCornerVector, finalCornerVector, bottomRightVector, bottomLeftVector, out intersectionVector)) { _logger.Log($"intersection ! {intersectionVector.X} | {intersectionVector.Y}"); HandleCollisionWithBlock(physicalView, intersectionVector); physicalView.V.Y = -physicalView.V.Y; physicalView.RealX += (float)(finalCornerVector.X - intersectionVector.X); physicalView.RealY += (float)(finalCornerVector.Y - intersectionVector.Y); } else if (SegmentHelper.LineSegementsIntersect(previousVectorCornerVector, finalCornerVector, bottomLeftVector, topLeftVector, out intersectionVector)) { _logger.Log($"intersection ! {intersectionVector.X} | {intersectionVector.Y}"); HandleCollisionWithBlock(physicalView, intersectionVector); physicalView.V.X = -physicalView.V.X; physicalView.RealX += (float)(finalCornerVector.X - intersectionVector.X); physicalView.RealY += (float)(finalCornerVector.Y - intersectionVector.Y); } } } } }
public ObjectData(string _key_name, SVector _position, SVector _euler) { keyName = _key_name; position = _position; euler = _euler; }
public Vector3(SVector old) { pX = old.pX; pY = old.pY; pZ = old.pZ; }
public static extern void SetSVectorProp(IntPtr node, [MarshalAs(UnmanagedType.LPStr)] string name, SVector val, [MarshalAs(UnmanagedType.LPStr)] string _typename = "ISSilentObject");
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SVector obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public bool configure(string policyName, SVector argv, bool skipFirstArgument) { bool ret = yarpPINVOKE.ResourceFinder_configure__SWIG_3(swigCPtr, policyName, SVector.getCPtr(argv), skipFirstArgument); if (yarpPINVOKE.SWIGPendingException.Pending) throw yarpPINVOKE.SWIGPendingException.Retrieve(); return ret; }
public SVector(SVector Obj_) { Pos = Obj_.Pos; Dir = Obj_.Dir; }