Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
hi. i need some codes about 2 square and the accidents that they have with each other.first of all, i need to have codes about a class for point and line. then with ''if'' method i should combine two square with each other and understand the position of the accident's points.
Posted 31-Dec-12 7:12am
Edited 31-Dec-12 7:27am
v2
Comments
OriginalGriff at 31-Dec-12 12:18pm
   
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
keivan ahmadian at 31-Dec-12 12:23pm
   
first of all, i need to have code about a class for point and line. then i should combine two square with each other and understand the position of the accident's points.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I believe what you are referring to is called "Collision Detection".
 
This[^] small tutorial from MSDN may help you along your way.
 
I also found this question in Q&A you can refer to: how to analyze whether a rectangle is overlap another rectangle[^]
  Permalink  
v2
Comments
keivan ahmadian at 31-Dec-12 12:34pm
   
yes, its exactly "Collision Detection". but i dont want grafically. i need the code. imagin 2 square in the space. show their position they have with each other.
Marcus Kramer at 31-Dec-12 12:43pm
   
Collision detection is never done graphically. Graphics are only employed to give a simple visual to the user of the underlying calculation.
keivan ahmadian at 9-Jan-13 14:26pm
   
what is the formula of collision detection in windows app form in c# ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Square_Point_Line
{
    public class Point
    {
        public Point()
        {
 
        }
 
        public Point(double x,double y)
        {
            this.X = x;
 
            this.Y = y;
        }
        public double X { get; set; }
 
        public double Y { get; set; }
 

        /// <summary>
        /// This Function Shows the Coordinates of the Point
        /// </summary>
        public void ShowPoint()
        {
            Console.WriteLine("\t\n [x={0},y={1}]",X,Y);
        }
    }
 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Square_Point_Line
{
 
    public class Line
    {
 
        public Line()
        {
 
        }
 
        public Line(Point a,Point b)
        {
            this.A = a;
 
            this.B = b;
 
        }
 
        public double Length
        {
            get
            {
                 return Math.Sqrt(Math.Pow(A.X - B.X, 2) + Math.Pow(A.Y - B.Y, 2));
            }
        }
 
        public Point A { get; set; }
 
        public Point B { get; set; }
 

        /// <summary>
        /// This Function Shows the Length of Line
        /// </summary>
        public void DisplayLine()
        {
            Console.WriteLine("LengthOfLine={0}",this.Length);
        }
    }
}
 

 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Square_Point_Line
{
    public class Square
    {
        public Square()
        {
 
        }
        public Square(Line ab,Line bc,Line cd,Line da)
        {
            this.AB = this.BC = this.CD = this.DA = ab;
        }
 
        public Square(Point a,Point b,Point c,Point d)
        {
            this.A = a;
            this.B = b;
            this.C = c;
            this.D = d;
        }
        public Line AB { get; set; }
        public Line BC { get; set; }
        public Line CD { get; set; }
        public Line DA { get; set; }
 
        public Point A { get; set; }
        public Point B { get; set; }
        public Point C { get; set; }
        public Point D { get; set; } 
   
    }
}
 
}
  Permalink  
Comments
keivan ahmadian at 1-Jan-13 9:40am
   
thank you. are these codes complete or they are a part of this project?
keivan ahmadian at 1-Jan-13 10:08am
   
ye soal mohandes jan. ina ro tooye botton bezaram ya ye textbox dorost konam?? age mishe lotf konid file zip ro baram email konid. keivankeivan90@yahoo.com
thank you very much.
behno0o0d at 1-Jan-13 10:51am
   
bebin ina 3 ta classe k man zire ham avordam inja, aval noghte ast, bad khatte, bad mshe square, doone doone class besaz,injoori behtar mshe ravande barnamat,bad hala mtuni too layeye presentation (hamoon programe khodemoon) vaghti noghteharo midi va bad lineha sakhte mshan va bad square ha ro tolid mkoni befahmi k aya ina tadakhol daran ba ham ya nadaran ;)faghat kafie bakhshe nahayi ro khodet benvisi
behno0o0d at 1-Jan-13 10:53am
   
ini k man neveshtam noktash ine k har class mtune yek noe dadeyi bashe ;);)
behno0o0d at 1-Jan-13 11:05am
   
ina k man neveshtam roo console hastesh, man form kar nakardam hanooz, barat mifrestam, bebin, baghish ba khodet ;)
keivan ahmadian at 9-Jan-13 14:22pm
   
behnood jan, class hash ke yekiye faghat baraye barkhord dadan bayad az methode ''if'' beram. age ashna dashti bepors dadash. :)
keivan ahmadian at 9-Jan-13 14:21pm
   
behnood jan, class hash ke yekiye faghat baraye barkhord dadan bayad az methode ''if'' beram. age ashna dashti bepors dadash. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 400
1 Maciej Los 222
2 OriginalGriff 213
3 BillWoodruff 130
4 Zoltán Zörgő 85
0 OriginalGriff 7,969
1 DamithSL 6,139
2 Sergey Alexandrovich Kryukov 5,449
3 Maciej Los 5,309
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 31 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100