Home > Net >  Mathematical skills primary school students, the two ways of implementation
Mathematical skills primary school students, the two ways of implementation

Time:09-26

1. Public List Getpoints (Point start Point, end, bool extension)
Start: the starting coordinates
End: end coordinates
The extension: whether to pixel line by starting point after it extend to the edge of the screen, if true is returned all the grid line coordinates
The return value: returns a List containing all of the pixel coordinates collection
Requirement: all mapped out the coordinates of 1 * 1 round result is displayed on the screen is a solid line
2. Public int Getangle (Point start Point, end)
After the return of the two points line to the starting point for the bottom of the degree

CodePudding user response:

 
Public List GetPoints (Point start Point, end, bool extension)
{
Bool isZhengX=end. X & gt; Start. X;//X is incremented
Bool isZhengY=end. Y & gt; Start. Y;//Y is incremented
Point pScreen=new Point (SystemInformation. PrimaryMonitorSize. Width, SystemInformation. PrimaryMonitorSize. Height);//screen coordinates biggest
Int xRange=end. X - start. X.
Int yRange=end. Y - start. Y;
List ListPoint=new List (a);
Int currX=start. X;
Int currY=start. Y;
If (xRange!=0)
{
Int destX=the extension? (isZhengX? PScreen. X: 0) : end. X.
While (isZhengX? CurrX & lt; DestX: currX & gt; DestX)
{
ListPoint. Add (new Point (currX, yRange==0? CurrY: ((int) (currX * (yRange/xRange (float))))));
CurrX=isZhengX? (currX + 1) : (currX - 1);
}
}
Else if (yRange!=0)
{
Int destY=the extension? (isZhengY? PScreen. Y: 0) : end. Y;
While (isZhengY? CurrY & lt; DestY: currY & gt; DestY)
{
ListPoint. Add (new Point (currX currY++));
}
}
Return listPoint;
}

Public double Getangle (Point start Point, end)
{
Double hudu=Math. Atan2 (end. Y - start. Y, end. X - start. X);//180 ° for PI
Double du=hudu * 180/Math. PI.
Return the du;
}

CodePudding user response:

reference 1st floor Bridge_go response:
 
Public List GetPoints (Point start Point, end, bool extension)
{
Bool isZhengX=end. X & gt; Start. X;//X is incremented
Bool isZhengY=end. Y & gt; Start. Y;//Y is incremented
Point pScreen=new Point (SystemInformation. PrimaryMonitorSize. Width, SystemInformation. PrimaryMonitorSize. Height);//screen coordinates biggest
Int xRange=end. X - start. X.
Int yRange=end. Y - start. Y;
List ListPoint=new List (a);
Int currX=start. X;
Int currY=start. Y;
If (xRange!=0)
{
Int destX=the extension? (isZhengX? PScreen. X: 0) : end. X.
While (isZhengX? CurrX & lt; DestX: currX & gt; DestX)
{
ListPoint. Add (new Point (currX, yRange==0? CurrY: ((int) (currX * (yRange/xRange (float))))));
CurrX=isZhengX? (currX + 1) : (currX - 1);
}
}
Else if (yRange!=0)
{
Int destY=the extension? (isZhengY? PScreen. Y: 0) : end. Y;
While (isZhengY? CurrY & lt; DestY: currY & gt; DestY)
{
ListPoint. Add (new Point (currX currY++));
}
}
Return listPoint;
}

Public double Getangle (Point start Point, end)
{
Double hudu=Math. Atan2 (end. Y - start. Y, end. X - start. X);//180 ° for PI
Double du=hudu * 180/Math. PI.
Return the du;
}

Thank you, back and I'll try

CodePudding user response:

Didn't understand the requirement of the first method

CodePudding user response:

 
Public List GetPoints (Point start Point, end, bool extension)
{
Bool isZhengX=end. X & gt; Start. X;//X is incremented
Bool isZhengY=end. Y & gt; Start. Y;//Y is incremented
Point pScreen=new Point (SystemInformation. PrimaryMonitorSize. Width, SystemInformation. PrimaryMonitorSize. Height);//screen coordinates biggest
Int xRange=end. X - start. X.
Int yRange=end. Y - start. Y;
List ListPoint=new List (a);
Int currX=start. X;
Int currY=start. Y;
Int destX=the extension? (isZhengX? PScreen. X: 0) : end. X.
Int destY=the extension? (isZhengY? PScreen. Y: 0) : end. Y;

If (xRange!=0)
{
While (isZhengX? CurrX & lt;=destX: currX & gt;=destX)
{
Int addy=(int) (currX - start. (X) * yRange/(float) xRange);
Int y=currY + addy;
If (isZhengY? Y & gt; DestY: y & lt; DestY)
{
break;
}
ListPoint. Add (new Point (currX, y));
CurrX=isZhengX? (currX + 1) : (currX - 1);
}
}
Else if (yRange!=0)
{
While (isZhengY? CurrY & lt;=destY: currY & gt;=destY)
{
ListPoint. Add (new Point (currX, isZhengY? CurrY++ : currY -));
}
}
Return listPoint;
}

CodePudding user response:

Computer graphics, please baidu

CodePudding user response:

1 what do you mean? To map the border?
  •  Tags:  
  • C#
  • Related