<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://www.dynomotion.com/wiki/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.dynomotion.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Geometric_Correction</id>
		<title>Geometric Correction - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://www.dynomotion.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Geometric_Correction"/>
		<link rel="alternate" type="text/html" href="https://www.dynomotion.com/wiki/index.php?title=Geometric_Correction&amp;action=history"/>
		<updated>2026-05-11T03:04:27Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.10</generator>

	<entry>
		<id>https://www.dynomotion.com/wiki/index.php?title=Geometric_Correction&amp;diff=490&amp;oldid=prev</id>
		<title>TK: Example KFLOP C Program to create Geocorrection Table</title>
		<link rel="alternate" type="text/html" href="https://www.dynomotion.com/wiki/index.php?title=Geometric_Correction&amp;diff=490&amp;oldid=prev"/>
				<updated>2018-07-08T17:56:17Z</updated>
		
		<summary type="html">&lt;p&gt;Example KFLOP C Program to create Geocorrection Table&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Example KFLOP PC Program to prompt Operator for a Rotation Angle and then create a 4 point [https://dynomotion.com/Help/KMotionCNC/GeoCorrection.htm Geocorrection Table] to apply this rotation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;brush:c&amp;quot;&amp;gt;#include &amp;quot;KMotionDef.h&amp;quot;&lt;br /&gt;
#define TMP 10 // which spare persist to use to transfer data&lt;br /&gt;
#include &amp;quot;KflopToKMotionCNCFunctions.c&amp;quot;&lt;br /&gt;
&lt;br /&gt;
// Create KMotionCNC GeoCorrection File based on simple Transformation&lt;br /&gt;
&lt;br /&gt;
double offsetx = 0.0;  // Transform values&lt;br /&gt;
double offsety = 0.0;&lt;br /&gt;
double theta = 0.0;&lt;br /&gt;
double scale = 1.0;&lt;br /&gt;
&lt;br /&gt;
void WriteGrid(int row, int col, FILE *f);&lt;br /&gt;
double TransformX(double x, double y);&lt;br /&gt;
double TransformY(double x, double y);&lt;br /&gt;
&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
    float value;&lt;br /&gt;
    &lt;br /&gt;
    // Ask Operator desired rotation angle&lt;br /&gt;
    if (!InputBox(&amp;quot;Enter Angle in degrees&amp;quot;,&amp;amp;value))  &lt;br /&gt;
    {&lt;br /&gt;
        theta = value * PI/180.0;  // convert to radians&lt;br /&gt;
        &lt;br /&gt;
        // Create Simple 4 point Geo File&lt;br /&gt;
        FILE *f=fopen(&amp;quot;C:\\Temp\\MapFile.txt&amp;quot;,&amp;quot;wt&amp;quot;);&lt;br /&gt;
        fprintf(f,&amp;quot;2,2\n&amp;quot;);        // rows, cols&lt;br /&gt;
        fprintf(f,&amp;quot;1,1\n&amp;quot;);        // gridx gridy&lt;br /&gt;
        fprintf(f,&amp;quot;-0.5,-0.5\n&amp;quot;);  // centerX centerY&lt;br /&gt;
&lt;br /&gt;
        WriteGrid(0, 0, f);  // write the 4 transformed points&lt;br /&gt;
        WriteGrid(0, 1, f);&lt;br /&gt;
        WriteGrid(1, 0, f);&lt;br /&gt;
        WriteGrid(1, 1, f);&lt;br /&gt;
        fclose(f);&lt;br /&gt;
        DoPC(PC_COMM_RELOAD_GEOCORRECTION);  // tell KMotionCNC to reload the file&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// write a transformed point to Geo File&lt;br /&gt;
void WriteGrid(int row, int col, FILE *f)&lt;br /&gt;
{&lt;br /&gt;
    double Centerx = 0.5;&lt;br /&gt;
    double Centery = 0.5;&lt;br /&gt;
    double x = col - Centerx;&lt;br /&gt;
    double y = row - Centery;&lt;br /&gt;
    fprintf(f,&amp;quot;%d,%d,%.11f,%.11f,0\n&amp;quot;, row, col, TransformX(x, y), TransformY(x, y));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Desired X Transformaion&lt;br /&gt;
double TransformX(double x, double y)&lt;br /&gt;
{&lt;br /&gt;
    return (scale * (x * cos(theta) - y * sin(theta))) + offsetx;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Desired Y Transformaion&lt;br /&gt;
double TransformY(double x, double y)&lt;br /&gt;
{&lt;br /&gt;
    return (scale * (x * sin(theta) + y * cos(theta))) + offsety;&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>TK</name></author>	</entry>

	</feed>