void AddParameterValues(Collection.List<float> parameters, Geometry2D.Single.Point vector, Geometry2D.Single.Point zero, Geometry2D.Single.Point one, Geometry2D.Single.Point two) { Geometry2D.Single.Point zerop = new Geometry2D.Single.Point(zero.X * vector.Y, zero.Y * vector.X); Geometry2D.Single.Point onep = new Geometry2D.Single.Point(one.X * vector.Y, one.Y * vector.X); Geometry2D.Single.Point twop = new Geometry2D.Single.Point(two.X * vector.Y, two.Y * vector.X); float zeroCoefficient = zerop.X - zerop.Y; float oneCoefficient = onep.X - onep.Y; float twoCoefficient = twop.X - twop.Y; if (twoCoefficient != 0) { zeroCoefficient /= twoCoefficient; oneCoefficient /= twoCoefficient; float s = Kean.Math.Single.Power(-oneCoefficient / 2, 2) - zeroCoefficient; if (s >= 0) { s = Kean.Math.Single.SquareRoot(s); float x1 = -oneCoefficient / 2 + s; float x2 = -oneCoefficient / 2 - s; if (x1 >= 0 && x1 <= 1) parameters.Add(x1); if (x2 >= 0 && x2 <= 1) parameters.Add(x2); } } else if (oneCoefficient != 0) { float x1 = -zeroCoefficient / oneCoefficient; if (x1 >= 0 && x1 <= 1) parameters.Add(x1); } }
public Geometry2D.Single.Box Bounds(Geometry2D.Single.Transform transform) { Geometry2D.Single.Box result = this.SegmentBounds(transform); if (this.Next.NotNull()) result = result.Union(this.Next.Bounds(transform)); return result; }
public Tuple<Geometry2D.Single.Point, Geometry2D.Single.Size> Correct(Geometry2D.Single.Point measurement) { Tuple<Geometry2D.Single.Point, Geometry2D.Single.Size> result; Matrix.Single correct = this.kalman.Correct(new Matrix.Single(1,2,new float[] {measurement.X, measurement.Y})); result = Tuple.Create(new Geometry2D.Single.Point(correct[0, 0], correct[0, 1]), new Geometry2D.Single.Size(correct[0, 2], correct[0, 3])); return result; }
protected override Geometry2D.Single.Box SegmentBounds(Geometry2D.Single.Transform transform) { Geometry2D.Single.Point p0 = this.Start; Geometry2D.Single.Point p1 = this.First; Geometry2D.Single.Point p2 = this.Second; Geometry2D.Single.Point p3 = this.End; Geometry2D.Single.Transform derivative = new Geometry2D.Single.Transform(transform.A, transform.B, transform.C, transform.D, 0, 0); Geometry2D.Single.Transform inverse = derivative.Inverse; Geometry2D.Single.Point e1p = inverse * new Geometry2D.Single.Point(1, 0); Geometry2D.Single.Point e2p = inverse * new Geometry2D.Single.Point(0, 1); Geometry2D.Single.Point zero = -3 * p0 + 3 * p1; Geometry2D.Single.Point one = 6 * p0 - 12 * p1 + 6 * p2; Geometry2D.Single.Point two = -3 * p0 + 9 * p1 - 9 * p2 + 3 * p3; Collection.List<float> parameters = new Collection.List<float>(); parameters.Add(0f); parameters.Add(1f); this.AddParameterValues(parameters, e1p, zero, one, two); this.AddParameterValues(parameters, e2p, zero, one, two); Geometry2D.Single.Point[] points = new Geometry2D.Single.Point[parameters.Count]; for (int i = 0; i < points.Length; i++) { //float alpha = i / (float)(points.Length - 1); float alpha = parameters[i]; Geometry2D.Single.Point current = Kean.Math.Single.Power(1 - alpha, 3) * p0 + 3 * Kean.Math.Single.Power(1 - alpha, 2) * alpha * p1 + 3 * (1 - alpha) * Kean.Math.Single.Power(alpha, 2) * p2 + Kean.Math.Single.Power(alpha, 3) * p3; points[i] = transform * current; } return Geometry2D.Single.Box.Bounds(points); }
public Image(Map map, Draw.Image image, Geometry2D.Single.Box source, Geometry2D.Single.Box destination) { this.Map = map; this.Data = image; this.Source = source; this.Destination = destination; }
protected YuvPlanar(Buffer.Sized buffer, Geometry2D.Integer.Size size, CoordinateSystem coordinateSystem, Geometry2D.Integer.Shell crop) : base(buffer, size, coordinateSystem, crop) { this.Y = this.CreateY(); this.U = this.CreateU(); this.V = this.CreateV(); }
public void Create(TextureType type, Geometry2D.Integer.Size size) { this.SetFormat(type, size); this.Use(); this.Create(IntPtr.Zero); this.UnUse(); }
protected Image(Geometry2D.Integer.Size size, CoordinateSystem coordinateSystem, Geometry2D.Integer.Shell crop) : base(size, coordinateSystem, crop) { this.LeftTop = new Geometry2D.Single.Point(0, 0); this.RightTop = new Geometry2D.Single.Point(1, 0); this.LeftBottom = new Geometry2D.Single.Point(0, 1); this.RightBottom = new Geometry2D.Single.Point(1, 1); }
protected override Geometry2D.Single.Box SegmentBounds(Geometry2D.Single.Transform transform) { Geometry2D.Single.Point startPoint = transform * this.Start; Geometry2D.Single.Point endPoint = transform * this.End; Geometry2D.Single.Point leftTop = new Geometry2D.Single.Point(Kean.Math.Single.Minimum(startPoint.X, endPoint.X), Kean.Math.Single.Minimum(startPoint.Y, endPoint.Y)); Geometry2D.Single.Size size = new Geometry2D.Single.Size(Kean.Math.Single.Absolute(startPoint.X - endPoint.X), Kean.Math.Single.Absolute(startPoint.Y - endPoint.Y)); return new Geometry2D.Single.Box(leftTop, size); }
public EllipticalArcTo(Geometry2D.Single.Size radius, float angle, bool largeArc, bool sweep, Geometry2D.Single.Point end) : base(end) { this.Radius = radius; this.Angle = angle; this.LargeArc = largeArc; this.Sweep = sweep; this.End = end; }
public override bool MoveCursor(Geometry2D.Integer.Size delta) { if (!this.noValidHandle) try { Console.CursorLeft += delta.Width; Console.CursorTop += delta.Height; } catch (System.IO.IOException) { this.noValidHandle = true; } return !this.noValidHandle; }
public Point(float measurementCovariance, float processCovariance, Geometry2D.Single.Point start, float startCovariance, Geometry2D.Single.Size velocity, float velocityCovariance) { Matrix.Single transition = new Kean.Math.Matrix.Single(4, 4, new float[] { 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1 }); Matrix.Single measurement = new Kean.Math.Matrix.Single(4, 2, new float[] { 1, 0, 0, 1, 0, 0, 0, 0 }); Matrix.Single measurementNoiseCovariance = measurementCovariance * Matrix.Single.Identity(2); Matrix.Single processNoiseCovariance = processCovariance * Matrix.Single.Identity(4); Matrix.Single initialState = new Kean.Math.Matrix.Single(1, 4, new float[] {start.X, start.Y, velocity.Width, velocity.Height}); Matrix.Single initialErrorCovariance = new Kean.Math.Matrix.Single(4, 4, new float[] { startCovariance, 0, 0, 0, 0, startCovariance, 0, 0, 0, 0, velocityCovariance, 0, 0, 0, 0, velocityCovariance }); this.kalman = new Kalman(transition, measurement, measurementNoiseCovariance, processNoiseCovariance,initialState, initialErrorCovariance, null); }
internal override void Render(Map map, Geometry2D.Single.Point leftTop, Geometry2D.Single.Point rightTop, Geometry2D.Single.Point leftBottom, Geometry2D.Single.Point rightBottom, Geometry2D.Single.Box destination) { if (map.NotNull()) map.Render(() => this.Channels[0].Backend.Render(leftTop, rightTop, leftBottom, rightBottom, destination), this.Channels); else { this.Channels[0].Backend.Use(); this.Channels[0].Backend.Render(leftTop, rightTop, leftBottom, rightBottom, destination); this.Channels[0].Backend.UnUse(); } }
public override bool MoveCursor(Geometry2D.Integer.Size delta) { IO.Text.Builder result = new IO.Text.Builder(); if (delta.Width > 0) result.Append("\x1b[{0}C", delta.Width); else if (delta.Width < 0) result.Append("\x1b[{0}D", -delta.Width); if (delta.Height > 0) result.Append("\x1b[{0}B", delta.Height); else if (delta.Height < 0) result.Append("\x1b[{0}A", -delta.Height); return this.Out.Write((string)result); }
public override void SetClip(Geometry2D.Single.Box region) { if (!region.Empty) { double[] left = new double[] { 1.0, 0.0, 0.0, -region.Left }; GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.ClipPlane0); GL.ClipPlane(OpenTK.Graphics.OpenGL.ClipPlaneName.ClipPlane0, ref left[0]); double[] right = new double[] { -1.0, 0.0, 0.0, region.Right }; GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.ClipPlane1); GL.ClipPlane(OpenTK.Graphics.OpenGL.ClipPlaneName.ClipPlane1, ref right[0]); double[] top = new double[] { 0.0, 1.0, 0.0, -region.Top }; GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.ClipPlane2); GL.ClipPlane(OpenTK.Graphics.OpenGL.ClipPlaneName.ClipPlane2, ref top[0]); double[] bottom = new double[] { 0.0, -1.0, 0.0, region.Bottom }; GL.Enable(OpenTK.Graphics.OpenGL.EnableCap.ClipPlane3); GL.ClipPlane(OpenTK.Graphics.OpenGL.ClipPlaneName.ClipPlane3, ref bottom[0]); } else this.UnSetClip(); }
protected override void SetFormat(TextureType type, Geometry2D.Integer.Size size) { switch (this.Type = type) { default: case TextureType.Rgba: this.InternalFormat = OpenTK.Graphics.OpenGL.PixelInternalFormat.Rgba; this.Format = OpenTK.Graphics.OpenGL.PixelFormat.Bgra; break; case TextureType.Rgb: this.InternalFormat = OpenTK.Graphics.OpenGL.PixelInternalFormat.Rgb; this.Format = OpenTK.Graphics.OpenGL.PixelFormat.Bgr; break; case TextureType.Monochrome: this.InternalFormat = OpenTK.Graphics.OpenGL.PixelInternalFormat.Luminance; this.Format = OpenTK.Graphics.OpenGL.PixelFormat.Luminance; break; } this.Size = this.Context.ClampTextureSize(size); }
internal void Render(Map map, Geometry2D.Single.Box source, Geometry2D.Single.Box destination) { if (this.Crop.NotZero) { source = (source).Intersection(this.Crop.Decrease(this.Size)); destination = ((Geometry2D.Single.Box)destination).Intersection(this.Crop.Decrease(this.Size)); } Geometry2D.Single.Point leftTop = new Geometry2D.Single.Point(source.Left / this.Size.Width, source.Top / this.Size.Height); Geometry2D.Single.Point rightTop = new Geometry2D.Single.Point(source.Right / this.Size.Width, source.Top / this.Size.Height); Geometry2D.Single.Point leftBottom = new Geometry2D.Single.Point(source.Left / this.Size.Width, source.Bottom / this.Size.Height); Geometry2D.Single.Point rightBottom = new Geometry2D.Single.Point(source.Right / this.Size.Width, source.Bottom / this.Size.Height); leftTop.X = this.LeftTop.X * (1 - leftTop.X) + this.RightTop.X * leftTop.X; rightTop.X = this.LeftTop.X * (1 - rightTop.X) + this.RightTop.X * rightTop.X; leftBottom.X = this.LeftBottom.X * (1 - leftBottom.X) + this.RightBottom.X * leftBottom.X; rightBottom.X = this.LeftBottom.X * (1 - rightBottom.X) + this.RightBottom.X * rightBottom.X; leftTop.Y = this.LeftTop.Y * (1 - leftTop.Y) + this.LeftBottom.Y * leftTop.Y; leftBottom.Y = this.LeftTop.Y * (1 - leftBottom.Y) + this.LeftBottom.Y * leftBottom.Y; rightTop.Y = this.RightTop.Y * (1 - rightTop.Y) + this.RightBottom.Y * rightTop.Y; rightBottom.Y = this.RightTop.Y * (1 - rightBottom.Y) + this.RightBottom.Y * rightBottom.Y; this.Render(map, leftTop, rightTop, leftBottom, rightBottom, destination); }
public Texture CreateTexture(TextureType type, Geometry2D.Integer.Size size) { this.Free(); Composition composition = this.compositionBin.Recycle(type, size); Texture result; if (composition.NotNull()) { composition.Renderer.Use(); composition.Renderer.UnSetClip(); composition.Renderer.Clear(); composition.Renderer.Unuse(); result = composition.Texture; } else result = this.textureBin.Recycle(type, size); if (result.IsNull()) { result = this.AllocateTexture(); result.Create(type, size); } return result; }
public Raster.Image Read(Geometry2D.Integer.Box region) { Raster.Packed result; switch (this.renderer.Type) { case OpenGL.Backend.TextureType.Rgb: result = new Raster.Bgr(this.Size, this.Image.CoordinateSystem, this.Image.Crop); break; case OpenGL.Backend.TextureType.Rgba: result = new Raster.Bgra(this.Size, this.Image.CoordinateSystem, this.Image.Crop); break; case OpenGL.Backend.TextureType.Monochrome: result = new Raster.Monochrome(this.Size, this.Image.CoordinateSystem, this.Image.Crop); break; default: result = null; break; } if (result.NotNull()) this.renderer.Read(result.Pointer, region); return result; }
public override Draw.Image Shift(Geometry2D.Integer.Size offset) { Raster.Image result = null; if (this is Monochrome) result = new Monochrome(this.Size); else if (this is Bgr) result = new Bgr(this.Size); else if (this is Bgra) result = new Bgra(this.Size); else if (this is Yuyv) result = new Yuyv(this.Size); int offsetX = Kean.Math.Integer.Modulo(this is Yuyv && Kean.Math.Integer.Modulo(offset.Width, 2) != 0 ? offset.Width + 1 : offset.Width, this.Size.Width); int length = (this.Size.Width - offsetX) * this.BytesPerPixel; int line = this.Size.Width * this.BytesPerPixel; for (int y = 0; y < this.Size.Height; y++) { int destination = Kean.Math.Integer.Modulo(y + offset.Height, this.Size.Height) * this.Stride; result.Buffer.CopyFrom(this.Buffer, this.Stride * y, destination + offsetX * this.BytesPerPixel, length); result.Buffer.CopyFrom(this.Buffer, this.Stride * y + length, destination, line - length); } return result; }
protected override Geometry2D.Single.Box SegmentBounds(Geometry2D.Single.Transform transform) { Geometry2D.Single.Box result = new Geometry2D.Single.Box(); Tuple<Geometry2D.Single.Point, float, float> coordinates = this.PlatformctArcCoordinates(); float startAngle = coordinates.Item2; float endAngle = coordinates.Item3; Geometry2D.Single.Transform derivative = new Geometry2D.Single.Transform(transform.A, transform.B, transform.C, transform.D, 0, 0); Geometry2D.Single.Transform inverse = derivative.Inverse; Geometry2D.Single.Point e1p = inverse * new Geometry2D.Single.Point(1, 0); Geometry2D.Single.Point e2p = inverse * new Geometry2D.Single.Point(0, 1); Collection.List<float> angles = new Collection.List<float>(); angles.Add(startAngle); angles.Add(endAngle); this.AnglesAdd(angles, Kean.Math.Single.ArcusTangensExtended(-e1p.X * this.Radius.Height, e1p.Y * this.Radius.Width), startAngle, endAngle); this.AnglesAdd(angles, Kean.Math.Single.ArcusTangensExtended(-e2p.X * this.Radius.Height, e2p.Y * this.Radius.Width), startAngle, endAngle); Geometry2D.Single.Point[] points = new Geometry2D.Single.Point[angles.Count]; for (int i = 0; i < points.Length; i++) { float angle = angles[i]; points[i] = transform * (new Geometry2D.Single.Point(this.Radius.Width * Kean.Math.Single.Cosinus(angle), this.Radius.Height * Kean.Math.Single.Sinus(angle)) + coordinates.Item1); } result = Geometry2D.Single.Box.Bounds(points); return result; }
public abstract void Draw(IColor color, Geometry2D.Single.Box region);
public abstract void Clear(Geometry2D.Single.Box region);
public abstract void Read(IntPtr pointer, Geometry2D.Integer.Box region);
public abstract void SetTransform(Geometry2D.Single.Transform transform);
public abstract void SetClip(Geometry2D.Single.Box region);
public Yuv444(Buffer.Sized buffer, Geometry2D.Integer.Size size, CoordinateSystem coordinateSystem, Geometry2D.Integer.Shell crop) : base(buffer, size, coordinateSystem, crop) { }
public Yuv444(Buffer.Sized buffer, Geometry2D.Integer.Size size) : this(buffer, size, CoordinateSystem.Default, new Geometry2D.Integer.Shell()) { }
public Yuv444(byte[] data, Geometry2D.Integer.Size size) : this(new Buffer.Vector<byte>(data), size) { }
public Yuv444(Geometry2D.Integer.Size size, CoordinateSystem coordinateSystem, Geometry2D.Integer.Shell crop) : this(new Buffer.Vector<byte>(3 * Packed.CalculateLength(size, 1)), size, coordinateSystem, crop) { }