# Design and Implementation of a Digital Twin System for Log Rotary Cutting Optimization
## 2 Materials and Methods
### Five-Dimensional Model
#### 2.1.5 Service System  
The service system refers to the functional services that encapsulate various models and algorithms required during the application of digital twins. This layer supports the internal functions of digital twins through tool components, middleware, and module engines in a service-oriented manner. In this paper, we design a service system to address the problem of high heterogeneity in wood. The system integrates the following tasks: interacting with the physical layer to obtain data frames containing sensor data, sensor IDs, and rotation angles; processing the data frames into 3D point cloud data by triangulation based on the sensor IDs; solving the coordinates of the center of the maximum inscribed cylinder by using the least squares method [18], as presented in Algorithm 1; reconstructing the 3D model of the point cloud data using the Delunary3d algorithm [19]; confirming the processing parameters based on the size of the maximum inscribed cylinder through kinematic analysis, including the card shaft motor speed and rotating cutter feed rate; and finally verifying the processing parameters by simulating the cutting process using a 3D Boolean operation [20] on the reconstructed model and outputting the estimated yield. The processing procedure of the rotary cutting system for logs involves finding the clamping point of the log after it is centered, removing the outer waste using the log de-barker, and finally machining it into a veneer with a veneer peeling machine. Therefore, two types of processing equipment are involved. Due to the different processing modes of the log debarker and the veneer peeling machine, kinematic analysis is separately conducted. The log debarker machine uses a cardan shaft processing mode, with two cardan shafts clamping the log to maintain a certain speed, and the rotating cutter moves linearly towards the log. In the rotary cutting process, the motion trajectory of a point on the cutting  
Figure 5: Data composition of the digital twin system for optimizing log rotary cutting. edge of the rotary cutter on the cross-section of the log can be called the rotary cutting curve. A coordinate system is established with the center of the log as the origin. During rotary cutting, the rotary cutter edge moves from point A to point B, with the distance between the rotary cutter blade and the horizontal plane of the cardan shaft axis being h, the veneer thickness being s, the instantaneous radius of the log being R, and the feeding speed of the rotary cutter edge being V (Figure 6). ```
1:Input:\(x_{i}\): The abscissa of log point cloud data;
2:\(y_{i}\): The ordinate of log point cloud data;
3:\(n\): The number of log point cloud data;
4:Output:\(a\): The abscissa of the center of the log's largest inscribed cylinder;
5:\(b\): The ordinate of the center of the log's largest inscribed cylinder;
6:\(r\): The radius of the center of the log's largest inscribed cylinder;
7:functionGetInsCylinderLog
8:for each \(x_{i},y_{i}\)do
9:\(f(x_{i},y_{i};a,b,r)=\min_{a,b,r}\sum_{i=1}^{n}\left(r^{2}-2 ax_{i}-2 by_{i}-a ^{2}-b^{2}\right)\)
10:\(\triangleright\) define the unknown model as a function
11:endfor
12:for each \(x_{i},y_{i}\)do
13:\(e_{i}=\sqrt{\left(x_{i}-a\right)^{2}+\left(y_{i}-b\right)^{2}}-r\); \(\triangleright\) build error function
14:endfor
15:for each \(x_{i},y_{i}\)do
16:\(\left\{