public ScalingTransform GetObjectCenteredScalingTransform(ChannelOutputs outputs) { ScalingTransform localSpaceTransform = GetJointCenteredScalingTransform(outputs); Vector3 centerPoint = CenterPoint.GetValue(outputs); return(ScalingTransform.FromTranslation(-centerPoint).Chain(localSpaceTransform).Chain(ScalingTransform.FromTranslation(+centerPoint))); }
private void OnTriggerEnter(Collider other) { ColorBall tempColorBall = other.gameObject.GetComponent <ColorBall>(); if (tempColorBall) { // Don't case equal for now lol if ((int)type > (int)tempColorBall.type) { type = GeneralTable.Combine(type, tempColorBall.type); BallColor = GeneralTable.GetColor(type); GamePlayManager.Instance.centerPoint.RemoveEstimateColorBallNum(); } else { Destroy(this.gameObject); } } CenterPoint tempCenterPoint = other.gameObject.GetComponent <CenterPoint>(); if (tempCenterPoint) { nextCenterPoint.match(type); ballCollider.enabled = false; } }
public void Verify() { if (CenterPoint == null) { throw new AnalyticalServicesException(24000, "CenterPoint must be supplied to the service."); } CenterPoint.Verify(); if (SearchHeading < 0 || SearchHeading > 360) { throw new AnalyticalServicesException(23600, "SearchHeading must be in the interval: [0-360]."); } if (Length <= 0) { throw new AnalyticalServicesException(23600, "Length must be greater than 0."); } if (Width <= 0) { throw new AnalyticalServicesException(23600, "Width must be greater than 0."); } if (Speed <= 0) { throw new AnalyticalServicesException(23600, "Speed must be greater than 0."); } }
public FPanel() { this.DoubleBuffered = true; this.font_x = new Font("Arial", 8); this.font_y = new Font("Arial", 8); this.points = new List <FPointColor>(); this.color_background_axis_step = 1; this.background_colour_points = null; this.is_have_background = false; this.axis_unit_points_x = new List <FPointUint>(); this.axis_unit_points_y = new List <FPointUint>(); this.is_have_function = false; this.function = null; this.Center_X = null; this.Center_Y = null; this.Xmin = 0; this.Xmax = 10; this.Ymin = 0; this.Ymax = 10; this.FindStepsAndCenter(); this.Paint += FPanel_Paint; this.SizeChanged += FPanel_SizeChanged; this.Invalidate(); }
private void ShowSearchArea() { if (MapDataParam.Info.UnitListCenterX == null || MapDataParam.Info.UnitListCenterY == null) { return; } if (MapDataParam.Info.UnitListCenterX.Count == 0 || MapDataParam.Info.UnitListCenterY.Count == 0) { return; } if (MapDataParam.Info.UnitListCenterX.Count != MapDataParam.Info.UnitListCenterY.Count) { return; } uint _RowCount = Convert.ToUInt32(numUpDownUnitRowCount.Value); uint _ColCount = Convert.ToUInt32(numUpDownUnitColumnCount.Value); int _TotalCount = MapDataParam.Info.UnitListCenterX.Count; if (_TotalCount != (_RowCount * _ColCount)) { MessageBox.Show(string.Format("Total : {0}, Row : {1}, Column : {2}", _TotalCount, _RowCount, _ColCount)); return; } CenterPoint[] _CenterPointArray = new CenterPoint[_TotalCount]; for (int iLoopCount = 0; iLoopCount < _TotalCount; ++iLoopCount) { _CenterPointArray[iLoopCount] = new CenterPoint(); _CenterPointArray[iLoopCount].X = MapDataParam.Info.UnitListCenterX[iLoopCount]; _CenterPointArray[iLoopCount].Y = MapDataParam.Info.UnitListCenterY[iLoopCount]; } CenterPoint[,] _SortedCenterPoint = CenterPointSort((uint)_RowCount, (uint)_ColCount, _CenterPointArray); MapDataParam.Info.UnitListCenterX.Clear(); MapDataParam.Info.UnitListCenterY.Clear(); for (int iLoopCount = 0; iLoopCount < _RowCount; ++iLoopCount) { for (int jLoopCount = 0; jLoopCount < _ColCount; ++jLoopCount) { MapDataParam.Info.UnitListCenterX.Add(_SortedCenterPoint[iLoopCount, jLoopCount].X); MapDataParam.Info.UnitListCenterY.Add(_SortedCenterPoint[iLoopCount, jLoopCount].Y); } } kpTeachDisplay.ClearDisplay(); for (int iLoopCount = 0; iLoopCount < MapDataParam.Info.UnitListCenterX.Count; ++iLoopCount) { CogRectangle _FindPattern = new CogRectangle(); _FindPattern.SetCenterWidthHeight(MapDataParam.Info.UnitListCenterX[iLoopCount], MapDataParam.Info.UnitListCenterY[iLoopCount], MapDataParam.Info.UnitListWidth[iLoopCount], MapDataParam.Info.UnitListHeight[iLoopCount]); kpTeachDisplay.DrawStaticShape(_FindPattern, "SearchArea" + (iLoopCount + 1)); CogPointMarker _OriginPoint = new CogPointMarker(); _OriginPoint.SetCenterRotationSize(MapDataParam.Info.UnitListCenterX[iLoopCount], MapDataParam.Info.UnitListCenterY[iLoopCount], 0, 2); kpTeachDisplay.DrawStaticShape(_OriginPoint, "PatternOrigin" + (iLoopCount + 1), CogColorConstants.Green, 12); kpTeachDisplay.DrawText((iLoopCount + 1).ToString(), MapDataParam.Info.UnitListCenterX[iLoopCount], MapDataParam.Info.UnitListCenterY[iLoopCount] - 15, CogColorConstants.Green, 10); } SelectingRectName = SelectedRectName = ""; IsDrawPatterns = true; }
public override string GetRequestUrl() { string pointStr = string.Format("LocationRecog/{0}?", CenterPoint.ToString()); string du; switch (DistanceUnits) { case DistanceUnitType.Miles: du = "mile"; break; case DistanceUnitType.Kilometers: default: du = "kilometer"; break; } List <string> param_list = new List <string> { string.Format("r={0}", Radius.ToString(System.Globalization.CultureInfo.InvariantCulture)), string.Format("top={0}", Top.ToString()), string.Format("distanceUnit={0}", du), string.Format("verboseplacenames={0}", VerbosePlaceNames.ToString().ToLower()), string.Format("key={0}", BingMapsKey.ToString()), string.Format("includeEntityTypes={0}", IncludeEntityTypes) }; if (DateTimeInput.HasValue) { param_list.Add(string.Format("dateTime={0}", DateTimeHelper.GetUTCString(DateTimeInput.Value))); } return(this.Domain + pointStr + string.Join("&", param_list)); }
public RigidTransform GetOriginToBindPoseTransform(ChannelOutputs outputs) { Vector3 orientationAngles = Orientation.GetValue(outputs); Vector3 centerPoint = CenterPoint.GetValue(outputs); Quaternion orientation = RotationOrder.DazStandard.FromEulerAngles(MathExtensions.DegreesToRadians(orientationAngles)); return(RigidTransform.FromRotationTranslation(orientation, centerPoint)); }
private DualQuaternion GetObjectCenteredRotationTransform(ChannelOutputs outputs, ScalingTransform parentScale) { DualQuaternion localSpaceTransform = GetJointCenteredRotationTransform(outputs, parentScale.Scale); Vector3 centerPoint = CenterPoint.GetValue(outputs); centerPoint = parentScale.Transform(centerPoint); return(DualQuaternion.FromTranslation(-centerPoint).Chain(localSpaceTransform).Chain(DualQuaternion.FromTranslation(+centerPoint))); }
public void SprawnCenterPoint(CenterPoint cpoint, GameObject thePoint) { Vector3 worldPosition; worldPosition.x = gameArea.transform.position.x; worldPosition.y = gameArea.transform.position.y;; worldPosition.z = 0f; cpoint.refCenterPoint = Instantiate(thePoint, worldPosition, cpoint.getRotation(), gameArea.transform); }
void UpdateAllTargets(ChaInfo character) { if (character) { centerPoint = new CenterPoint(character); customTargets = UpdateCustomTargets(character); quickTargets = UpdateQuickTargets(character); } }
protected override void GetAttributes() { attrs.Clear(); attrs.Add("centerpoint", CenterPoint.ToString()); string str = ""; foreach (var item in ConnectedPipes) { str += ModelIdManager.toString(item.BaseModelId) + ","; } attrs.Add("connectedpipes", str); if (this.OwnSolution != null) { attrs.Add("solution", Utils.ModelIdManager.toString(this.OwnSolution.BaseModelId)); } attrs.Add("style", ((int)Style).ToString()); }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <returns></returns> protected override bool Equals(DesignScriptEntity obj) { if (base.Equals(obj)) { return(true); } var arc = obj as DSArc; if (arc == null) { return(false); } return(CenterPoint.Equals(arc.CenterPoint) && Normal.Equals(arc.Normal) && DSGeometryExtension.Equals(Radius, arc.Radius)); }
/// <summary> /// /// </summary> /// <param name="obj"></param> /// <returns></returns> protected override bool Equals(DesignScriptEntity obj) { if (base.Equals(obj)) { return(true); } var other = obj as Circle; if (obj == null || other == null) { return(false); } return(CenterPoint.Equals(other.CenterPoint) && GeometryExtension.Equals(Radius, other.Radius) && Normal.Equals(other.Normal)); }
public void ClearAll() { this.font_x = new Font("Arial", 8); this.font_y = new Font("Arial", 8); this.background_colour_points = null; this.Center_X = null; this.Center_Y = null; this.is_have_background = false; this.axis_unit_points_x.Clear(); this.axis_unit_points_y.Clear(); this.is_have_function = false; this.function = null; this.Xmin = 0; this.Xmax = 10; this.Ymin = 0; this.Ymax = 10; this.points.Clear(); this.FindStepsAndCenter(); this.Invalidate(); }
public void UpdateAllTargets(CharInfo character) { if (character) { allTargets = normalTargets = UpdateNormalTargets(character); customTargets = UpdateCustomTargets(character); customTargets.ForEach(target => allTargets.Add(target.GetTarget())); centerPoint = new CenterPoint(character); if (centerPoint != null && centerPoint.GetPoint()) { allTargets.Add(centerPoint.GetPoint()); } movementPoint = new MovementPoint(character); allTargets.Add(movementPoint.GetPoint()); } else { if (centerPoint != null) { GameObject.Destroy(centerPoint.GetPoint()); centerPoint = null; } if (movementPoint != null) { GameObject.Destroy(movementPoint.GetPoint()); movementPoint = null; } for (int i = 0; i < customTargets.Count; i++) { GameObject.Destroy(customTargets[i].GetTarget()); } allTargets = new List <GameObject>(); normalTargets = new List <GameObject>(); customTargets = new List <CustomTarget>(); } }
void HandleOnUnite() { //List<Point2D> allPoint = ActualPoints; Edge2D[] centerEdges = CenterPoint.Edges.ToArray(); //Debug.Log("Center Edges Count : " + centerEdges.Length); for (int i = 0; i < centerEdges.Length; i++) { centerEdges[i].DestorySelf(); } CenterPoint.DestroySelf(); CenterPoint = null; foreach (var e in BasicEdges) { e.DivisionCount--; if (e.DivisionCount == 0) { Edge2D[] middleEdges = e.MiddlePoint.Edges.ToArray(); for (int i = 0; i < middleEdges.Length; i++) { middleEdges[i].DestorySelf(); } e.OnUnite(); } } foreach (var child in Childern) { Shape.RemoveFace(child); } Shape.AddFace(this); Childern.Clear(); }
public IBrush ToItem(AGSSerializationContext context) { switch (Type) { case BrushType.Solid: return(_brushes.LoadSolidBrush(Color.FromHexa(MainColor))); case BrushType.Linear: return(_brushes.LoadLinearBrush(LinearColors.Select(c => Color.FromHexa(c)).ToArray(), Blend.ToItem(context), InterpolationColors.ToItem(context), Transform.ToItem(context), WrapMode, GammaCorrection)); case BrushType.Hatch: return(_brushes.LoadHatchBrush(HatchStyle, Color.FromHexa(MainColor), Color.FromHexa(BackgroundColor))); case BrushType.Path: return(_brushes.LoadPathsGradientBrush(Color.FromHexa(MainColor), CenterPoint.ToItem(context), Blend.ToItem(context), FocusScales.ToItem(context), LinearColors.Select(c => Color.FromHexa(c)).ToArray(), InterpolationColors.ToItem(context), Transform.ToItem(context), WrapMode)); default: throw new NotSupportedException(Type + " brush is not supported!"); } }
/// <summary> /// Xác định ví trí tương đối giữa 2 hình tròn /// </summary> /// <param name="c2">Hình tròn cần xác đính vị trí với hình hiện tại</param> /// <returns> /// </returns> public RELATIVECIRCLE RelativePosition(Circle c2) { double c1c2 = CenterPoint.Distance(c2.CenterPoint); double r1Cr2 = Radius + c2.Radius; double r1Tr2 = System.Math.Abs(Radius - c2.Radius); if (c1c2 > r1Cr2) { return(RELATIVECIRCLE.LyingOutside); } if (c1c2 == r1Cr2) { return(RELATIVECIRCLE.TouchingExternally); } if (c1c2 == r1Tr2) { return(RELATIVECIRCLE.TouchingInternally); } if (c1c2 < r1Tr2) { return(RELATIVECIRCLE.OneLyingInsideOther); } return(RELATIVECIRCLE.IntersectingAtTwoPoints); }
public Judgement(float tchTime, float pointT, CenterPoint refPoint) { touchTime = tchTime; pointTime = pointT; referencePoint = (GameObject)refPoint.refCenterPoint; }
private void SetItemsPos() { double sz; double x; double y; double isz; double ix; double iy; CalcCoos(out x, out y, out sz, out ix, out iy, out isz); OuterBorder.SetValue(Canvas.LeftProperty, x); OuterBorder.SetValue(Canvas.TopProperty, y); OuterBorder.Width = sz; OuterBorder.Height = sz; InnerBorder.SetValue(Canvas.LeftProperty, ix); InnerBorder.SetValue(Canvas.TopProperty, iy); InnerBorder.Width = isz; InnerBorder.Height = isz; if (Brush != null) { CenterPoint.SetValue(Canvas.LeftProperty, ix + Brush.Center.X * isz - CenterPoint.Width / 2.0); CenterPoint.SetValue(Canvas.TopProperty, iy + Brush.Center.Y * isz - CenterPoint.Height / 2.0); RadiusXPoint.SetValue(Canvas.LeftProperty, ix + (Brush.Center.X + Brush.RadiusX) * isz - RadiusXPoint.Width / 2.0); RadiusXPoint.SetValue(Canvas.TopProperty, iy + Brush.Center.Y * isz - RadiusXPoint.Height / 2.0); RadiusYPoint.SetValue(Canvas.LeftProperty, ix + Brush.Center.X * isz - RadiusYPoint.Width / 2.0); RadiusYPoint.SetValue(Canvas.TopProperty, iy + (Brush.Center.Y + Brush.RadiusY) * isz - RadiusYPoint.Height / 2.0); OriginXLine.SetValue(Canvas.LeftProperty, ix + Brush.GradientOrigin.X * isz - OriginXLine.Width / 2.0); OriginYLine.SetValue(Canvas.TopProperty, iy + Brush.GradientOrigin.Y * isz - OriginYLine.Height / 2.0); OriginXY.SetValue(Canvas.LeftProperty, ix + Brush.GradientOrigin.X * isz - OriginXY.Width / 2.0); OriginXY.SetValue(Canvas.TopProperty, iy + Brush.GradientOrigin.Y * isz - OriginXY.Height / 2.0); RadialEllipse.SetValue(Canvas.LeftProperty, ix + (Brush.Center.X - Brush.RadiusX) * isz); RadialEllipse.SetValue(Canvas.TopProperty, iy + (Brush.Center.Y - Brush.RadiusY) * isz); RadialEllipse.Width = 2.0 * Brush.RadiusX * isz; RadialEllipse.Height = 2.0 * Brush.RadiusY * isz; CenterPoint.Visibility = Visibility.Visible; RadiusXPoint.Visibility = Visibility.Visible; RadiusYPoint.Visibility = Visibility.Visible; OriginXLine.Visibility = Visibility.Visible; OriginYLine.Visibility = Visibility.Visible; OriginXY.Visibility = Visibility.Visible; RadialEllipse.Visibility = Visibility.Visible; } else { CenterPoint.Visibility = Visibility.Collapsed; RadiusXPoint.Visibility = Visibility.Collapsed; RadiusYPoint.Visibility = Visibility.Collapsed; OriginXLine.Visibility = Visibility.Collapsed; OriginYLine.Visibility = Visibility.Collapsed; OriginXY.Visibility = Visibility.Collapsed; RadialEllipse.Visibility = Visibility.Collapsed; } }
public override string ToString() { string s = "P1: " + P1.ToString() + " P2: " + P2.ToString() + " CenterPoint: " + CenterPoint.ToString(); return(s); }
private void FindStepsAndCenter() { this.axis_unit_points_x.Clear(); this.axis_unit_points_y.Clear(); if (this.Xmax >= 0 && this.Xmin >= 0) { this.MAX_X = this.Xmax - this.Xmin; } else if (this.Xmax <= 0 && this.Xmin <= 0) { this.MAX_X = Math.Abs(Xmin) - Math.Abs(Xmax); } else if (this.Xmin <= 0 && this.Xmax >= 0) { this.MAX_X = Math.Abs(Xmin) + Math.Abs(Xmax); } if (this.Ymax >= 0 && this.Ymin >= 0) { this.MAX_Y = this.Ymax - this.Ymin; } else if (this.Ymax <= 0 && this.Ymin <= 0) { this.MAX_Y = Math.Abs(Ymin) - Math.Abs(Ymax); } else if (this.Ymin <= 0 && this.Ymax >= 0) { this.MAX_Y = Math.Abs(Ymin) + Math.Abs(Ymax); } //step************************************* this.Step_X = this.MAX_X / this.Width; this.Step_Y = this.MAX_Y / this.Height; //X**************************************** if (this.Xmax >= 0 && this.Xmin >= 0) { this.Center_X = new CenterPoint(5, this.Xmin); } else if (this.Xmax <= 0 && this.Xmin <= 0) { this.Center_X = new CenterPoint(this.Width - 5, this.Xmax); } else if (this.Xmin <= 0 && this.Xmax >= 0) { this.Center_X = new CenterPoint(Math.Abs(Xmin) / this.Step_X, 0); } //Y******************************** if (this.Ymax >= 0 && this.Ymin >= 0) { this.Center_Y = new CenterPoint(this.Height - 5, this.Ymin); } else if (this.Ymax <= 0 && this.Ymin <= 0) { this.Center_Y = new CenterPoint(5, this.Ymax); } else if (this.Ymin <= 0 && this.Ymax >= 0) { this.Center_Y = new CenterPoint(Math.Abs(this.Ymax) / this.Step_Y, 0); } //axis_step********************************** double number_step_x = (this.Width - 10) / MAX_X; double number_step_y = (this.Height - 10) / MAX_Y; if (MAX_X < 2) { this.axis_unit_X = 0.1; this.font_x = new Font("Arial", 10, FontStyle.Bold); number_step_x *= this.axis_unit_X; } else if (MAX_X >= 2 && MAX_X < 10) { this.axis_unit_X = 0.5; this.font_x = new Font("Arial", 9, FontStyle.Bold); number_step_x *= this.axis_unit_X; } else if (MAX_X >= 10 && MAX_X < 30) { this.axis_unit_X = 1; this.font_x = new Font("Arial", 8, FontStyle.Bold); number_step_x *= this.axis_unit_X; } else if (MAX_X >= 30 && MAX_X < 100) { this.axis_unit_X = 2; this.font_x = new Font("Arial", 7, FontStyle.Bold); number_step_x *= this.axis_unit_X; } else { this.axis_unit_X = 5; this.font_x = new Font("Arial", 6, FontStyle.Bold); number_step_x *= this.axis_unit_X; } if (MAX_Y < 2) { this.axis_unit_Y = 0.1; this.font_y = new Font("Arial", 10, FontStyle.Bold); number_step_y *= this.axis_unit_Y; } else if (MAX_Y >= 2 && MAX_Y < 10) { this.axis_unit_Y = 0.5; this.font_y = new Font("Arial", 9, FontStyle.Bold); number_step_y *= this.axis_unit_Y; } else if (MAX_Y >= 10 && MAX_Y < 30) { this.axis_unit_Y = 1; this.font_y = new Font("Arial", 8, FontStyle.Bold); number_step_y *= this.axis_unit_Y; } else if (MAX_Y >= 30 && MAX_Y < 100) { this.axis_unit_Y = 2; this.font_y = new Font("Arial", 7, FontStyle.Bold); number_step_y *= this.axis_unit_Y; } else { this.axis_unit_Y = 5; this.font_y = new Font("Arial", 6, FontStyle.Bold); number_step_y *= this.axis_unit_Y; } if (this.Xmax >= 0 && this.Xmin >= 0) { double start_to_right = this.Center_X.XY; double unit_to_right = this.Xmin; while (true) { start_to_right += number_step_x; unit_to_right += this.axis_unit_X; if (start_to_right > this.Width) { break; } if (this.Center_Y.XY >= (this.Height - 15)) { this.axis_unit_points_x.Add(new FPointUint(start_to_right - 5, this.Center_Y.XY - 15, start_to_right, this.Center_Y.XY, unit_to_right)); } else { this.axis_unit_points_x.Add(new FPointUint(start_to_right - 5, this.Center_Y.XY, start_to_right, this.Center_Y.XY, unit_to_right)); } } } else if (this.Xmax <= 0 && this.Xmin <= 0) { double start_to_left = this.Center_X.XY; double unit_to_left = this.Xmax; while (true) { start_to_left -= number_step_x; unit_to_left -= this.axis_unit_X; if (start_to_left < 0) { break; } if (this.Center_Y.XY >= (this.Height - 15)) { this.axis_unit_points_x.Add(new FPointUint(start_to_left - 5, this.Center_Y.XY - 15, start_to_left, this.Center_Y.XY, unit_to_left)); } else { this.axis_unit_points_x.Add(new FPointUint(start_to_left - 5, this.Center_Y.XY, start_to_left, this.Center_Y.XY, unit_to_left)); } } } else if (this.Xmin <= 0 && this.Xmax >= 0) { double start_to_right = this.Center_X.XY; double unit_to_right = 0; while (true) { start_to_right += number_step_x; unit_to_right += this.axis_unit_X; if (start_to_right > this.Width) { break; } if (this.Center_Y.XY >= (this.Height - 15)) { this.axis_unit_points_x.Add(new FPointUint(start_to_right - 5, this.Center_Y.XY - 15, start_to_right, this.Center_Y.XY, unit_to_right)); } else { this.axis_unit_points_x.Add(new FPointUint(start_to_right - 5, this.Center_Y.XY, start_to_right, this.Center_Y.XY, unit_to_right)); } } double start_to_left = this.Center_X.XY; double unit_to_left = 0; while (true) { start_to_left -= number_step_x; unit_to_left -= this.axis_unit_X; if (start_to_left < 0) { break; } if (this.Center_Y.XY >= (this.Height - 15)) { this.axis_unit_points_x.Add(new FPointUint(start_to_left - 5, this.Center_Y.XY - 15, start_to_left, this.Center_Y.XY, unit_to_left)); } else { this.axis_unit_points_x.Add(new FPointUint(start_to_left - 5, this.Center_Y.XY, start_to_left, this.Center_Y.XY, unit_to_left)); } } } if (this.Ymax >= 0 && this.Ymin >= 0) { double start_to_up = this.Center_Y.XY; double unit_to_up = this.Ymin; while (true) { start_to_up -= number_step_y; unit_to_up += this.axis_unit_Y; if (start_to_up < 0) { break; } if (this.Center_X.XY >= (this.Width - 15)) { this.axis_unit_points_y.Add(new FPointUint(this.Center_X.XY - 15, start_to_up - 5, this.Center_X.XY, start_to_up, unit_to_up)); } else { this.axis_unit_points_y.Add(new FPointUint(this.Center_X.XY, start_to_up - 5, this.Center_X.XY, start_to_up, unit_to_up)); } } } else if (this.Ymax <= 0 && this.Ymin <= 0) { double start_to_down = this.Center_Y.XY; double unit_to_down = this.Ymax; while (true) { start_to_down += number_step_y; unit_to_down -= this.axis_unit_Y; if (start_to_down > this.Height) { break; } if (this.Center_X.XY >= (this.Width - 15)) { this.axis_unit_points_y.Add(new FPointUint(this.Center_X.XY - 15, start_to_down - 5, this.Center_X.XY, start_to_down, unit_to_down)); } else { this.axis_unit_points_y.Add(new FPointUint(this.Center_X.XY, start_to_down - 5, this.Center_X.XY, start_to_down, unit_to_down)); } } } else if (this.Ymin <= 0 && this.Ymax >= 0) { double start_to_up = this.Center_Y.XY; double unit_to_up = 0; while (true) { start_to_up -= number_step_y; unit_to_up += this.axis_unit_Y; if (start_to_up < 0) { break; } if (this.Center_X.XY >= (this.Width - 15)) { this.axis_unit_points_y.Add(new FPointUint(this.Center_X.XY - 15, start_to_up - 5, this.Center_X.XY, start_to_up, unit_to_up)); } else { this.axis_unit_points_y.Add(new FPointUint(this.Center_X.XY, start_to_up - 5, this.Center_X.XY, start_to_up, unit_to_up)); } } double start_to_down = this.Center_Y.XY; double unit_to_down = 0; while (true) { start_to_down += number_step_y; unit_to_down -= this.axis_unit_Y; if (start_to_down > this.Height) { break; } if (this.Center_X.XY >= (this.Width - 15)) { this.axis_unit_points_y.Add(new FPointUint(this.Center_X.XY - 15, start_to_down - 5, this.Center_X.XY, start_to_down, unit_to_down)); } else { this.axis_unit_points_y.Add(new FPointUint(this.Center_X.XY, start_to_down - 5, this.Center_X.XY, start_to_down, unit_to_down)); } } } }
private void btnFindSearchArea_Click(object sender, EventArgs e) { double _OffsetX = MapDataParam.Unit.PatternAreaOriginX - MapDataParam.Unit.PatternAreaCenterX; double _OffsetY = MapDataParam.Unit.PatternAreaOriginY - MapDataParam.Unit.PatternAreaCenterY; InspPattern.SetPatternReference(MapDataParam.Info.UnitPattern); InspPattern.SetMatchingParameter(MapDataParam.Info.FindCount, MapDataParam.Info.FindScore); if (false == InspPattern.Run(OriginImage)) { MessageBox.Show("Pattern Not Found"); return; } CogPMAlignResults _PatternResult = InspPattern.GetResults(); if (null == _PatternResult) { return; } MapDataParam.Info.UnitListCenterX.Clear(); MapDataParam.Info.UnitListCenterY.Clear(); MapDataParam.Info.UnitListWidth.Clear(); MapDataParam.Info.UnitListHeight.Clear(); if (_PatternResult.Count > 0) { double[] _OriginX, _OriginY, _CenterX, _CenterY, _Width, _Height; _OriginX = new double[_PatternResult.Count]; _OriginY = new double[_PatternResult.Count]; _CenterX = new double[_PatternResult.Count]; _CenterY = new double[_PatternResult.Count]; _Width = new double[_PatternResult.Count]; _Height = new double[_PatternResult.Count]; uint _RowCount = Convert.ToUInt32(numUpDownUnitRowCount.Value); uint _ColCount = Convert.ToUInt32(numUpDownUnitColumnCount.Value); CenterPoint[] _CenterPointArray = new CenterPoint[_RowCount * _ColCount]; for (int iLoopCount = 0; iLoopCount < _PatternResult.Count; ++iLoopCount) { _OriginX[iLoopCount] = _PatternResult[iLoopCount].GetPose().TranslationX; _OriginY[iLoopCount] = _PatternResult[iLoopCount].GetPose().TranslationY; _CenterX[iLoopCount] = _PatternResult[iLoopCount].GetPose().TranslationX - _OffsetX; _CenterY[iLoopCount] = _PatternResult[iLoopCount].GetPose().TranslationY - _OffsetY; _Width[iLoopCount] = _PatternResult.GetTrainArea().Width; _Height[iLoopCount] = _PatternResult.GetTrainArea().Height; CogRectangle _FindPattern = new CogRectangle(); _FindPattern.SetCenterWidthHeight(_CenterX[iLoopCount], _CenterY[iLoopCount], MapDataParam.Unit.SearchAreaWidth, MapDataParam.Unit.SearchAreaHeight); kpTeachDisplay.DrawStaticShape(_FindPattern, "SearchArea" + (iLoopCount + 1)); CogPointMarker _OriginPoint = new CogPointMarker(); _OriginPoint.SetCenterRotationSize(_OriginX[iLoopCount], _OriginY[iLoopCount], 0, 2); kpTeachDisplay.DrawStaticShape(_OriginPoint, "PatternOrigin" + (iLoopCount + 1), CogColorConstants.Green, 12); MapDataParam.Info.UnitListCenterX.Add(_CenterX[iLoopCount]); MapDataParam.Info.UnitListCenterY.Add(_CenterY[iLoopCount]); MapDataParam.Info.UnitListWidth.Add(_Width[iLoopCount]); MapDataParam.Info.UnitListHeight.Add(_Height[iLoopCount]); if (_CenterPointArray.Length > iLoopCount) { _CenterPointArray[iLoopCount] = new CenterPoint(); _CenterPointArray[iLoopCount].X = _CenterX[iLoopCount]; _CenterPointArray[iLoopCount].Y = _CenterY[iLoopCount]; } } if ((_RowCount * _ColCount) != _PatternResult.Count) { MessageBox.Show("Unit 개수와 Find Result 개수가 맞지 않습니다."); return; } else { CenterPoint[,] _SortedCenterPoint = CenterPointSort(_RowCount, _ColCount, _CenterPointArray); MapDataParam.Info.UnitListCenterX.Clear(); MapDataParam.Info.UnitListCenterY.Clear(); for (int iLoopCount = 0; iLoopCount < _RowCount; ++iLoopCount) { for (int jLoopCount = 0; jLoopCount < _ColCount; ++jLoopCount) { MapDataParam.Info.UnitListCenterX.Add(_SortedCenterPoint[iLoopCount, jLoopCount].X); MapDataParam.Info.UnitListCenterY.Add(_SortedCenterPoint[iLoopCount, jLoopCount].Y); } } SelectingRectName = SelectedRectName = ""; IsDrawPatterns = true; MessageBox.Show("Pattern Find Complete"); } } }
public override string UniqueString() { return("Circle " + CenterPoint.ToString() + " " + Radius + " " + FillColor); }
private void btnManualSearchAreaSet_Click(object sender, EventArgs e) { uint _RowCount = Convert.ToUInt32(numUpDownUnitRowCount.Value); uint _ColCount = Convert.ToUInt32(numUpDownUnitColumnCount.Value); CogRectangle _WholePatternRegion = kpTeachDisplay.GetInterActiveRectangle(); MapDataParam.Whole.SearchAreaCenterX = _WholePatternRegion.CenterX; MapDataParam.Whole.SearchAreaCenterY = _WholePatternRegion.CenterY; MapDataParam.Whole.SearchAreaWidth = _WholePatternRegion.Width; MapDataParam.Whole.SearchAreaHeight = _WholePatternRegion.Height; double _Width, _Height; _Width = _WholePatternRegion.Width / _ColCount; _Height = _WholePatternRegion.Height / _RowCount; double _StartCenterPointX, _StartCenterPointY, _CenterPointX, _CenterPointY; _StartCenterPointX = _WholePatternRegion.X + _Width / 2; _StartCenterPointY = _WholePatternRegion.Y + _Height / 2; kpTeachDisplay.ClearDisplay(); MapDataParam.Info.UnitListCenterX.Clear(); MapDataParam.Info.UnitListCenterY.Clear(); MapDataParam.Info.UnitListWidth.Clear(); MapDataParam.Info.UnitListHeight.Clear(); CogRectangle[,] _PatternRegions = new CogRectangle[_RowCount, _ColCount]; CenterPoint[] _CenterPointArray = new CenterPoint[_RowCount * _ColCount]; int _Index = 0; for (int iLoopCount = 0; iLoopCount < _RowCount; ++iLoopCount) { _CenterPointY = _StartCenterPointY + (_Height * iLoopCount); for (int jLoopCount = 0; jLoopCount < _ColCount; ++jLoopCount) { _CenterPointX = _StartCenterPointX + (_Width * jLoopCount); _PatternRegions[iLoopCount, jLoopCount] = new CogRectangle(); _PatternRegions[iLoopCount, jLoopCount].SetCenterWidthHeight(_CenterPointX, _CenterPointY, _Width, _Height); MapDataParam.Info.UnitListCenterX.Add(_PatternRegions[iLoopCount, jLoopCount].CenterX); MapDataParam.Info.UnitListCenterY.Add(_PatternRegions[iLoopCount, jLoopCount].CenterY); MapDataParam.Info.UnitListWidth.Add(_PatternRegions[iLoopCount, jLoopCount].Width); MapDataParam.Info.UnitListHeight.Add(_PatternRegions[iLoopCount, jLoopCount].Height); _CenterPointArray[_Index] = new CenterPoint(); _CenterPointArray[_Index].X = _PatternRegions[iLoopCount, jLoopCount].CenterX; _CenterPointArray[_Index].Y = _PatternRegions[iLoopCount, jLoopCount].CenterY; _Index++; } } CenterPoint[,] _SortedCenterPoint = CenterPointSort(_RowCount, _ColCount, _CenterPointArray); MapDataParam.Info.UnitListCenterX.Clear(); MapDataParam.Info.UnitListCenterY.Clear(); for (int iLoopCount = 0; iLoopCount < _RowCount; ++iLoopCount) { for (int jLoopCount = 0; jLoopCount < _ColCount; ++jLoopCount) { MapDataParam.Info.UnitListCenterX.Add(_SortedCenterPoint[iLoopCount, jLoopCount].X); MapDataParam.Info.UnitListCenterY.Add(_SortedCenterPoint[iLoopCount, jLoopCount].Y); } } btnShowSearchArea_Click(null, null); }
void Update() { if (currentSpeed > endSpeed) { currentSpeed -= speedDecreaseRate * Time.deltaTime; if (currentSpeed < endSpeed) { currentSpeed = endSpeed; } } if (nextWaypoint) { tempPos = this.transform.position; tempNextPos = nextWaypoint.transform.position; tempDirection = tempNextPos - tempPos; tempDirection.y = 0; tempDirection.Normalize(); // speed tempDirection *= currentSpeed; this.transform.position = new Vector3(tempPos.x + (tempDirection.x * Time.deltaTime), tempPos.y, tempPos.z + (tempDirection.z * Time.deltaTime)); tempResultPos = this.transform.position; /*Debug.Log("====T " + tempPos.ToString()); * Debug.Log("====N " + tempNextPos.ToString()); * Debug.Log("====R " + tempResultPos.ToString()); * Debug.Log("^^ 1: " + ((tempPos.x - tempNextPos.x) * (tempResultPos.x - tempNextPos.x))); * Debug.Log("^^ 2: " + ((tempPos.z - tempNextPos.z) * (tempResultPos.z - tempNextPos.z)));*/ if (((tempPos.x - tempNextPos.x) * (tempResultPos.x - tempNextPos.x)) <= 0 && ((tempPos.z - tempNextPos.z) * (tempResultPos.z - tempNextPos.z)) <= 0) { this.transform.position = new Vector3(tempNextPos.x, this.transform.position.y, tempNextPos.z); if (nextWaypoint.GetNextWaypoint()) { nextWaypoint = nextWaypoint.GetNextWaypoint(); } else { nextCenterPoint = nextWaypoint.GetCenterPoint(); nextWaypoint = null; } } } else if (nextCenterPoint) { tempPos = this.transform.position; tempNextPos = nextCenterPoint.transform.position; tempDirection = tempNextPos - tempPos; tempDirection.y = 0; tempDirection.Normalize(); // speed tempDirection *= currentSpeed; this.transform.position = new Vector3(tempPos.x + (tempDirection.x * Time.deltaTime), this.transform.position.y, tempPos.z + (tempDirection.z * Time.deltaTime)); tempResultPos = this.transform.position; // to the center, just destroy if (((tempPos.x - tempNextPos.x) * (tempResultPos.x - tempNextPos.x)) <= 0 && ((tempPos.z - tempNextPos.z) * (tempResultPos.z - tempNextPos.z)) <= 0) { this.transform.position = tempNextPos; Destroy(this.gameObject); } } else { Debug.LogError("#### No next target, should be destroyed!"); } }
private CenterPoint[,] CenterPointSort(uint _RowCount, uint _ColCount, CenterPoint[] _CenterPointArray) { int _Index = 0; CenterPoint[,] _SortedCenterPoint = new CenterPoint[_RowCount, _ColCount]; //Y 축 방향으로 오름차순 정렬 Array.Sort(_CenterPointArray, delegate(CenterPoint _First, CenterPoint _Second) { return(_First.Y.CompareTo(_Second.Y)); }); for (int iLoopCount = 0; iLoopCount < _RowCount; ++iLoopCount) { var _CenterPointReferY = new CenterPoint[_ColCount]; for (int jLoopCount = 0; jLoopCount < _ColCount; ++jLoopCount) { _CenterPointReferY[jLoopCount] = _CenterPointArray[_Index++]; } //if (iLoopCount % 2 == 1) Array.Sort(_CenterPointReferY, delegate (CenterPoint _First, CenterPoint _Second) { return _Second.X.CompareTo(_First.X); }); //지그재그 //else Array.Sort(_CenterPointReferY, delegate (CenterPoint _First, CenterPoint _Second) { return _First.X.CompareTo(_Second.X); }); //노멀 if (eSearchType.NORMAL == (eSearchType)MapDataParam.Info.SearchType) { Array.Sort(_CenterPointReferY, delegate(CenterPoint _First, CenterPoint _Second) { return(_First.X.CompareTo(_Second.X)); }); //노멀 } else if (eSearchType.NORMAL_REV == (eSearchType)MapDataParam.Info.SearchType) { Array.Sort(_CenterPointReferY, delegate(CenterPoint _First, CenterPoint _Second) { return(_Second.X.CompareTo(_First.X)); }); //노멀 } else if (eSearchType.ZIGZAG == (eSearchType)MapDataParam.Info.SearchType) { if (iLoopCount % 2 == 1) { Array.Sort(_CenterPointReferY, delegate(CenterPoint _First, CenterPoint _Second) { return(_Second.X.CompareTo(_First.X)); }); } else { Array.Sort(_CenterPointReferY, delegate(CenterPoint _First, CenterPoint _Second) { return(_First.X.CompareTo(_Second.X)); }); } } else if (eSearchType.ZIGZAG_REV == (eSearchType)MapDataParam.Info.SearchType) { if (iLoopCount % 2 == 0) { Array.Sort(_CenterPointReferY, delegate(CenterPoint _First, CenterPoint _Second) { return(_Second.X.CompareTo(_First.X)); }); //지그재그 } else { Array.Sort(_CenterPointReferY, delegate(CenterPoint _First, CenterPoint _Second) { return(_First.X.CompareTo(_Second.X)); }); //노멀 } } for (int jLoopCount = 0; jLoopCount < _ColCount; ++jLoopCount) { _SortedCenterPoint[iLoopCount, jLoopCount] = new CenterPoint(); _SortedCenterPoint[iLoopCount, jLoopCount] = _CenterPointReferY[jLoopCount]; } } return(_SortedCenterPoint); }
public double GetDistanceSquareToCenter(PointModel p) { return(CenterPoint.GetDistanceSquare(p)); }