コード例 #1
0
ファイル: PhotoTag.cs プロジェクト: icd-lab/d-flip-series
 public PhotoTag(List<String> tags)
 {
     foreach (String t in tags)
         tagBox[t] = new BoundingBox2D();
     allTags = tags;
     activeTagList = new List<String>();
 }
コード例 #2
0
ファイル: FloatTextBox.cs プロジェクト: icd-lab/d-flip-series
 public Vector2 showAgain(Vector2 pos)
 {
     this.Location = new System.Drawing.Point((int)(pos.X + SystemParameter.clientBounds.Min.X), (int)(pos.Y + SystemParameter.clientBounds.Min.Y));
     this.Show();
     IsShown = true;
     boundingBox = new BoundingBox2D(new Vector2(pos.X, pos.Y), new Vector2(pos.X + width, pos.Y + height), 0f);
     return new Vector2(pos.X + this.Width, pos.Y);
 }
コード例 #3
0
        public bool Overrap(BoundingBox2D boundingBox, ref Vector2 dir, ref float dira)
        {
            #if NO_ROTATION
            Vector2 a = Max - boundingBox.Min;
            Vector2 b = boundingBox.Max - Min;

            if ((a.X > 0) && (a.Y > 0) && (b.X > 0) && (b.Y > 0))
            {
                dir.X = (a.Y < b.Y) ? a.Y : b.Y;
                dir.Y = (a.X < b.X) ? a.X : b.X;
                dir.X = (a.X < b.X) ? -dir.X : dir.X;
                dir.Y = (a.Y < b.Y) ? -dir.Y : dir.Y;
                return true;
            }
            return false;
            #else
            bool contain = false;
            dir = Vector2.Zero;
            dira = 0f;
            Vector2 ca = (Min + Max) * 0.5f;
            Vector2 cb = (boundingBox.Min + boundingBox.Max) * 0.5f;
            for (int i = 0; i < 4; ++i)
            {
                if (boundingBox.Contains(Vertex[i]) == ContainmentType.Contains)
                {
                    contain = true;
                    int n = 0;
                    double distMin = double.MaxValue;
                    Vector2 bv2av = Vector2.Zero;
                    for (int j = 0; j < 4; ++j)
                    {
                        Vector2 buni = boundingBox.Vertex[(j + 1) % 4] - boundingBox.Vertex[j];
                        buni.Normalize();
                        bv2av = Vertex[i] - boundingBox.Vertex[j];
                        double dist = Math.Abs(bv2av.X * buni.Y - bv2av.Y * buni.X);
                        if (distMin > dist)
                        {
                            distMin = dist;
                            n = j;
                        }
                    }
                    Vector2 v1 = ca - Vertex[i];
                    v1.Normalize();
                    Vector2 v2 = boundingBox.Vertex[(n + 1) % 4] - boundingBox.Vertex[(n + 2) % 4];
                    v2.Normalize();
                    dir += v1 * (float)(distMin * Math.Abs(v1.X * v2.X + v1.Y * v2.Y));
                    dira += -(v1.X * v2.Y - v1.Y * v2.X);
                }
            }
            for (int i = 0; i < 4; ++i)
            {
                if (Contains(boundingBox.Vertex[i]) == ContainmentType.Contains)
                {
                    contain = true;
                    int n = 0;
                    double distMin = double.MaxValue;
                    Vector2 av2bv = Vector2.Zero;
                    for (int j = 0; j < 4; ++j)
                    {
                        Vector2 auni = Vertex[(j + 1) % 4] - Vertex[j];
                        auni.Normalize();
                        av2bv = boundingBox.Vertex[i] - Vertex[j];
                        double dist = Math.Abs(av2bv.X * auni.Y - av2bv.Y * auni.X);
                        if (distMin > dist)
                        {
                            distMin = dist;
                            n = j;
                        }
                    }
                    Vector2 v2 = Vertex[(n + 2) % 4] - Vertex[(n + 1) % 4];
                    v2.Normalize();
                    Vector2 v1 = ca - (boundingBox.Vertex[i] - (float)distMin * v2);
                    v1.Normalize();
                    dir += v1 * (float)(distMin * Math.Abs(v1.X * v2.X + v1.Y * v2.Y));
                    dira += -(v1.X * v2.Y - v1.Y * v2.X);
                }
            }
            if (!contain)
            {
                if ((ca - cb).Length() < 0.5f * (Math.Min(Max.X - Min.X, Max.Y - Min.Y) + Math.Min(boundingBox.Max.X - boundingBox.Min.X, boundingBox.Max.Y - boundingBox.Min.Y)))
                {
                    contain = true;
                    Vector2 x = (Max.X - Min.X) * Vector2.UnitX;
                    Vector2 y = (Max.Y - Min.Y) * Vector2.UnitY;
                    if (ca.X < cb.X)
                    {
                        dir += -x;
                    }
                    else
                    {
                        dir += x;
                    }
                    if (ca.Y < cb.Y)
                    {
                        dir += -y;
                    }
                    else
                    {
                        dir += y;
                    }
                    dir *= 2f;
                }
            }
            return contain;
            #endif
        }
コード例 #4
0
ファイル: Photo.cs プロジェクト: icd-lab/d-flip-series
        /// <summary>
        /// アトラクター選択後の処理
        /// </summary>
        public void End()
        {
            if (isDel_)
            {
                scale_ -= 0.5f;
            }
            else
            {
                position_ += velocity_ * (1.0f / 60.0f);
                scale_ += vscale_ * (1.0f / 60.0f);
            #if NO_ROTATION
            #else
                angle_ += (float)(Math.Sign(vangle_) * Math.PI) * (1.0f / 60.0f);
                while (angle_ > Math.PI)
                {
                    angle_ -= (float)Math.PI * 2f;
                }
                while (angle_ < -Math.PI)
                {
                    angle_ += (float)Math.PI * 2f;
                }
            #endif
            }

            //bounding box
            if (IsGazeds && ptag.allTags != null && maxTagSize.Count == 2 && ptag.allTags.Count > 0)
            {
                //ptag.createBox(this.PositionDisplay.X + this.WidthDisplay / 2, this.PositionDisplay.Y - this.HeightDisplay / 2, angleDisplay_);
                int positionLarger = (int)Math.Max(position_.Y - center_.Y * scale_ - (float)((1d - Math.Exp(-(double)scale_)) * (double)ResourceManager.MAR + 2d) + maxTagSize[1], position_.Y + center_.Y * scale_ + (float)((1d - Math.Exp(-(double)scale_)) * (double)ResourceManager.MAR + 2d));
                int positionDisplayLarger = (int)Math.Max(positionDisplay_.Y - center_.Y * scaleDisplay_ - (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)ResourceManager.MAR + 2d) + maxTagSize[1], positionDisplay_.Y + center_.Y * scaleDisplay_ + (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)ResourceManager.MAR + 2d));

                boundingBox_ = new BoundingBox2D(
                  position_ - center_ * scale_ - Vector2.One * (float)((1d - Math.Exp(-(double)scale_)) * (double)ResourceManager.MAR + 2d),
                  new Vector2(position_.X + center_.X * scale_ + (float)((1d - Math.Exp(-(double)scale_)) * (double)ResourceManager.MAR + 2d) + maxTagSize[0], positionLarger), angle_);
                boundingBoxDisplay_ = new BoundingBox2D(
                    positionDisplay_ - center_ * scaleDisplay_ - Vector2.One * (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)ResourceManager.MAR + 2d),
                    new Vector2(positionDisplay_.X + center_.X * scaleDisplay_ - (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)ResourceManager.MAR + 2d) + maxTagSize[0], positionDisplayLarger), angleDisplay_);

            }
            else
            {
                boundingBox_ = new BoundingBox2D(
                  position_ - center_ * scale_ - Vector2.One * (float)((1d - Math.Exp(-(double)scale_)) * (double)ResourceManager.MAR + 2d),
                  position_ + center_ * scale_ + Vector2.One * (float)((1d - Math.Exp(-(double)scale_)) * (double)ResourceManager.MAR + 2d), angle_);
                boundingBoxDisplay_ = new BoundingBox2D(
                    positionDisplay_ - center_ * scaleDisplay_ - Vector2.One * (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)ResourceManager.MAR + 2d),
                    positionDisplay_ + center_ * scaleDisplay_ - Vector2.One * (float)((1d - Math.Exp(-(double)scaleDisplay_)) * (double)ResourceManager.MAR + 2d), angleDisplay_);
            }
        }