1. A machine tool comprising:a table having a workpiece setting surface to which a workpiece is fixed;
a spindle equipped with a tool configured to perform flattening on the workpiece fixed to the table;
a workpiece flattening control unit configured to perform flattening on the workpiece using the tool in a manner that machining areas of the tool on a surface of the workpiece partially overlap one another;
at least one contact element arranged on the spindle at a position that faces the table;
a contact-element position storing unit configured to store multiple measured values that are obtained by performing measurement of a position of the contact element at least two times in a state where the spindle is set at at least one phase and the contact element is positioned at an identical point;
a spindle tilt angle calculating unit configured to calculate a tilt angle of the spindle with respect to an XY-plane for machining, based on the multiple measured values stored in the contact-element position storing unit; and,
a coordinate system rotation unit configured to rotate the XY-plane about at least one of X-axis and Y-axis, based on the tilt angle of the spindle calculated by the spindle tilt angle calculating unit,
wherein the workpiece flattening control unit machines a flat surface of the workpiece along the XY-plane rotated by the coordinate system rotation unit.