Skip to content

Instantly share code, notes, and snippets.

@bradmartin333
Last active August 4, 2021 00:04
Show Gist options
  • Save bradmartin333/6abf99ac9b98d219fa12704d9baed838 to your computer and use it in GitHub Desktop.
Save bradmartin333/6abf99ac9b98d219fa12704d9baed838 to your computer and use it in GitHub Desktop.
using System;
using System.Drawing;
using System.IO;
namespace XYZmanipulator
{
class Program
{
static void Main()
{
using StreamWriter sw = new(@"C:\Users\delta\Desktop\scanFormat2.txt");
string line;
int idx = 0;
float radius = 25;
PointF center = new(42, 50);
RectangleF rectangleOuter = new(32, 40, 20, 20);
RectangleF rectangleInner = new(36, 44, 12, 12);
StreamReader file = new(@"C:\Users\delta\Desktop\scan.txt");
while ((line = file.ReadLine()) != null)
{
idx++;
string[] vs = line.Split('\t');
float X = float.Parse(vs[0]);
float Y = float.Parse(vs[1]);
float Z = float.Parse(vs[2]);
string lineF = string.Format("{0}\t{1}\t{2}",
Math.Round(X,2),
Math.Round(Y,2),
Math.Round(Z-7,2));
PointF pointF = new(X, Y);
double distance = Math.Sqrt(Math.Pow(X - center.X, 2) + Math.Pow(Y - center.Y, 2));
if (idx % 25 == 0)
{
if (distance > radius)
sw.WriteLine(lineF);
else if (rectangleOuter.Contains(pointF) && !rectangleInner.Contains(pointF))
sw.WriteLine(lineF);
}
else if (idx % 500 == 0)
sw.WriteLine(lineF);
}
file.Close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment