Last active
December 14, 2015 15:58
-
-
Save atodorova/5111649 to your computer and use it in GitHub Desktop.
3D-Space.UI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Globalization; | |
class Space3D | |
{ | |
static void Main() | |
{ | |
CultureInfo.CreateSpecificCulture("en-US"); | |
Point3D firstPoint = new Point3D(5.2, 6.3, 7.4); | |
Point3D secondPoint = new Point3D(9, 10, 12); | |
Point3D turthPoint = new Point3D(1, 2, 3); | |
Path points = new Path(); | |
points.AddingPoints(firstPoint); | |
points.AddingPoints(secondPoint); | |
points.AddingPoints(turthPoint); | |
PathStorage listOfPoints = new PathStorage(); | |
listOfPoints.SavePaths(points); | |
listOfPoints.LoadPaths(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public static class Distance | |
{ | |
public static double CalculateDistance(Point3D firstPoint, Point3D secondPoint) | |
{ | |
double distanceByX = firstPoint.PointCoordX - secondPoint.PointCoordX; | |
double distanceByY = firstPoint.PointCoordY - secondPoint.PointCoordY; | |
double distanceByZ = firstPoint.PointCoordZ - secondPoint.PointCoordZ; | |
double distance3D = Math.Sqrt(Math.Pow(distanceByX, 2) + Math.Pow(distanceByY, 2) + Math.Pow(distanceByZ, 2)); | |
return distance3D; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
public struct Point3D | |
{ | |
public double PointCoordX { get; set; } | |
public double PointCoordY { get; set; } | |
public double PointCoordZ { get; set; } | |
public static readonly Point3D startPoint = new Point3D(0,0,0); | |
public Point3D(double pointCoordX, double pointCoordY, double pointCoordZ): this() | |
{ | |
this.PointCoordX = pointCoordX; | |
this.PointCoordY = pointCoordY; | |
this.PointCoordZ = pointCoordZ; | |
} | |
public override string ToString() | |
{ | |
CultureInfo en = new CultureInfo("en-US"); | |
string pointCoordinates = string.Format( | |
"PointCoonrinates are: X = {0}, Y = {1}, Z = {2}", this.PointCoordX.ToString(en), this.PointCoordY.ToString(en), this.PointCoordZ.ToString(en)); | |
return pointCoordinates; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
using System.IO; | |
class PathStorage | |
{ | |
public void SavePaths(Path path) | |
{ | |
using(StreamWriter output = new StreamWriter(@"../../output.txt")) | |
{ | |
foreach (var item in path.PointsSequence) | |
{ | |
output.WriteLine(item); | |
} | |
} | |
path.PointsSequence.Clear(); | |
} | |
public void LoadPaths() | |
{ | |
using (StreamReader output = new StreamReader(@"../../output.txt")) | |
{ | |
int lineNumber = 1; | |
string lineContent = output.ReadLine(); | |
Point3D point = new Point3D(); | |
Path path = new Path(); | |
while (lineContent != null) | |
{ | |
lineContent = lineContent.Remove(0, 21); | |
string[] pointsCoords = lineContent.Split(','); | |
point.PointCoordX = double.Parse(pointsCoords[0].Remove(0, 5), CultureInfo.InvariantCulture); | |
point.PointCoordY = double.Parse(pointsCoords[1].Remove(0, 5), CultureInfo.InvariantCulture); | |
point.PointCoordZ = double.Parse(pointsCoords[2].Remove(0, 5), CultureInfo.InvariantCulture); | |
path.AddingPoints(point); | |
Console.WriteLine(point); | |
lineContent = output.ReadLine(); | |
lineNumber++; | |
} | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
public struct Point3D | |
{ | |
public double PointCoordX { get; set; } | |
public double PointCoordY { get; set; } | |
public double PointCoordZ { get; set; } | |
public static readonly Point3D startPoint = new Point3D(0,0,0); | |
public Point3D(double pointCoordX, double pointCoordY, double pointCoordZ): this() | |
{ | |
this.PointCoordX = pointCoordX; | |
this.PointCoordY = pointCoordY; | |
this.PointCoordZ = pointCoordZ; | |
} | |
public override string ToString() | |
{ | |
CultureInfo en = new CultureInfo("en-US"); | |
string pointCoordinates = string.Format( | |
"PointCoonrinates are: X = {0}, Y = {1}, Z = {2}", this.PointCoordX.ToString(en), this.PointCoordY.ToString(en), this.PointCoordZ.ToString(en)); | |
return pointCoordinates; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment