12,884,771 members (32,676 online)
Rate this:
See more:
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 6:12am
Updated 31-Dec-12 6:27am
v2
OriginalGriff 31-Dec-12 12:18pm

This is not a good question - we cannot work out from that little what you are trying to do.
Use the "Improve question" widget to edit your question and provide better information.

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:

## Solution 2

I believe what you are referring to is called "Collision Detection".

I also found this question in Q&A you can refer to: how to analyze whether a rectangle is overlap another rectangle[^]
v2

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 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.

what is the formula of collision detection in windows app form in c# ?
Rate this:

## 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; }

}
}

}```

thank you. are these codes complete or they are a part of this project?

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 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 1-Jan-13 10:53am

ini k man neveshtam noktash ine k har class mtune yek noe dadeyi bashe ;);)
behno0o0d 1-Jan-13 11:05am

ina k man neveshtam roo console hastesh, man form kar nakardam hanooz, barat mifrestam, bebin, baghish ba khodet ;)

behnood jan, class hash ke yekiye faghat baraye barkhord dadan bayad az methode ''if'' beram. age ashna dashti bepors dadash. :)

behnood jan, class hash ke yekiye faghat baraye barkhord dadan bayad az methode ''if'' beram. age ashna dashti bepors dadash. :)

Top Experts
Last 24hrsThis month
 OriginalGriff 310 Jochen Arndt 175 CHill60 150 Maciej Los 100 ppolymorphe 95
 OriginalGriff 4,162 CHill60 2,508 Karthik Bangalore 2,416 Jochen Arndt 2,173 ppolymorphe 1,895