Skip to content

Instantly share code, notes, and snippets.

@Myvar
Created December 19, 2017 13:46
Show Gist options
  • Save Myvar/5e500b34ca276f0eafb1913c8934a0f6 to your computer and use it in GitHub Desktop.
Save Myvar/5e500b34ca276f0eafb1913c8934a0f6 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
namespace Test
{
public class Point
{
public int X { get; set; }
public int Y { get; set; }
public Point(int x, int y)
{
X = x;
Y = y;
}
public float TriangleArea(Point b, Point c)
{
float x1 = b.X - X;
float y1 = b.Y - Y;
float x2 = c.X - X;
float y2 = c.Y - Y;
return (x1 * y2 - x2 * y1);
}
}
public class PointF
{
public float X { get; set; }
public float Y { get; set; }
public PointF(float x, float y)
{
X = x;
Y = y;
}
public float TriangleArea(Point b, Point c)
{
float x1 = b.X - X;
float y1 = b.Y - Y;
float x2 = c.X - X;
float y2 = c.Y - Y;
return (x1 * y2 - x2 * y1);
}
}
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
Console.Clear();
var v0 = new Point(146, 186);
var Scale = new PointF(0.022f, -0.022f);
var Transform = new Point(0, 24);
v0.X = (int) ((float) v0.X * Scale.X);
v0.Y = (int) ((float) v0.Y * Scale.Y);
v0.X += Transform.X;
v0.Y += Transform.Y;
Console.WriteLine($"X is {v0.X}, expected awnser is 3");
Console.WriteLine($"Y is {v0.Y}, expected awnser is 20");
}
protected override void Run()
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment