OpenToonz - An open-source full-featured 2D animation creation software
C
Translate comments to English
Campbell Bartona6cacc8cf1d5
diff --git a/toonz/sources/common/tapptools/tcolorutils.cpp b/toonz/sources/common/tapptools/tcolorutils.cppindex 8c8a6fb78..8203a5c60 100644--- a/toonz/sources/common/tapptools/tcolorutils.cpp+++ b/toonz/sources/common/tapptools/tcolorutils.cpp@@ -26,12 +26,12 @@ typedef float KEYER_FLOAT;class ClusterStatistic {public:- KEYER_FLOAT sumComponents[3]; // vettore 3x1+ KEYER_FLOAT sumComponents[3]; // vector 3x1unsigned int elemsCount;- KEYER_FLOAT matrixR[9]; // matrice 3x3 = somma(x * trasposta(x))- // dove x sono i pixel del cluster+ KEYER_FLOAT matrixR[9]; // matrix 3x3 = sum(x * transposed(x))+ // where x are the pixels in the cluster- KEYER_FLOAT covariance[9]; // matrice di covarianza+ KEYER_FLOAT covariance[9]; // covariance matrixTPoint sumCoords;#ifdef WITH_ALPHA_IN_STATISTICS@@ -178,13 +178,12 @@ void chooseLeafToClusterize(ClusterContainer::iterator &itRet,KEYER_FLOAT tmpEigenValue;Cluster *cluster = *it;- // calcola la matrice di covarianza+ // Calculates the covariance matrix.const KEYER_FLOAT *clusterCovariance = cluster->statistic.covariance;assert(!ISNAN(clusterCovariance[0]));- // calcola gli autovalori della matrice di covarianza della statistica- // del cluster (siccome la matrice e' symmetrica gli autovalori- // sono tutti reali)+ // Calculate the eigenvalues of the covariance matrix of the cluster statistics+ // (because the array is symmetrical the eigenvalues are all real)KEYER_FLOAT eigenValues[3];tmpMulteplicity = calcCovarianceEigenValues(clusterCovariance, eigenValues);assert(tmpMulteplicity > 0);@@ -192,7 +191,7 @@ void chooseLeafToClusterize(ClusterContainer::iterator &itRet,tmpEigenValue = std::max({eigenValues[0], eigenValues[1], eigenValues[2]});cluster->eigenValue = tmpEigenValue;- // eventuale aggiornamento del cluster da cercare+ // Check if there are any cluster updates to search for.if (itFound == clusters.end()) {itFound = it;maxEigenValue = tmpEigenValue;@@ -212,7 +211,7 @@ void chooseLeafToClusterize(ClusterContainer::iterator &itRet,itRet = itFound;eigenValue = maxEigenValue;- // calcola l'autovettore relativo a maxEigenValue+ // Calculates the eigenvector related to 'maxEigenValue'Cluster *clusterFound = *itFound;assert(multeplicity > 0);@@ -328,7 +327,7 @@ void chooseLeafToClusterize(ClusterContainer::iterator &itRet,assert(false && "impossibile!!");}- // normalizzazione dell'autovettore calcolato+ // Normalization of calculated eigenvector./*KEYER_FLOAT eigenVectorMagnitude = sqrt(eigenVector[0]*eigenVector[0] +eigenVector[1]*eigenVector[1] +@@ -460,18 +459,19 @@ static void clusterize(ClusterContainer &clusters, int clustersCount) {unsigned int clustersSize = clusters.size();assert(clustersSize >= 1);- // faccio in modo che in clusters ci siano solo e sempre le foglie- // dell'albero calcolato secondo l'algoritmo TSE descritto da Orchard-Bouman+ // Ensure the clusters are always leaves.+ // Tree calculated using the algorithm described by Orchard TSE - Bouman.// (c.f.r. "Color Quantization of Images" - M.Orchard, C. Bouman)- // numero di iterazioni, numero di cluster = numero di iterazioni + 1+ // number of iterations , the number of clusters = number of iterations + 1int m = clustersCount - 1;int i = 0;for (; i < m; ++i) {- // sceglie la foglia dell'albero dei cluster (ovvero il cluster nel- // ClusterContainer "clusters") che ha il maggiore autovalore, ovvero- // il cluster che ha maggiore varainza rispetto all'asse opportuno- // (che poi e' l'autovettore corrispondente all'autovalore piu' grande)+ // Choose the cluster leaf of the tree (the cluster in+ // ClusterContainer "clusters") that has the highest eigenvalue, ie+ // The cluster that has higher variance axis+ // (which is the eigenvector corresponding to the largest eigenvalue).+KEYER_FLOAT eigenValue = 0.0;KEYER_FLOAT eigenVector[3] = {0.0, 0.0, 0.0};ClusterContainer::iterator itChoosedCluster;@@ -483,24 +483,24 @@ static void clusterize(ClusterContainer &clusters, int clustersCount) {#if 0- // se il cluster che si e' scelto per la suddivisione contiene un solo- // elemento vuol dire che non c'e' piu' niente da suddividere e si esce- // dal ciclo.- // Questo succede quando si sono chiesti piu' clusters di quanti elementi- // ci sono nel cluster iniziale.+ // If the cluster chosen for the subdivision contains single+ // element means that there's nothing left to divide up and exit+ // the loop.+ // This happens when checking how many more clusters of elements+ // there are in the initial cluste.if(choosedCluster->statistic.elemsCount == 1)break;#else- // un cluster che ha un solo elemento non ha molto senso di esistere,- // credo crei problemi anche nel calcolo della matrice di covarianza,- // quindi mi fermo quando il cluster contiene meno di 4 elementi+ // A cluster that has only one element doesn't make much sense to exist,+ // It also creates problems in the computation of the covariance matrix.+ // Stop when the cluster contains less than 4 elements.if (choosedCluster->statistic.elemsCount == 3) break;#endif- // suddivide il cluster scelto in altri due cluster+ // Subdivides the cluster chosen in two other clusters.Cluster *subcluster1 = new Cluster();Cluster *subcluster2 = new Cluster();split(subcluster1, subcluster2, eigenVector, choosedCluster);@@ -509,10 +509,10 @@ static void clusterize(ClusterContainer &clusters, int clustersCount) {if ((subcluster1->data.size() == 0) || (subcluster2->data.size() == 0))break;- // calcola la nuova statistica per subcluster1+ // Calculates the new report for 'subcluster1'.subcluster1->computeStatistics();- // calcola la nuova statistica per subcluster2+ // Calculates the new statistic for 'subcluster2'.int j = 0;for (; j < 3; ++j) {subcluster2->statistic.sumComponents[j] =@@ -542,10 +542,10 @@ static void clusterize(ClusterContainer &clusters, int clustersCount) {subcluster2->computeCovariance();- // aggiorna in modo opportuno il ClusterContainer "clusters", cancellando- // il cluster scelto e inserendo i due appena creati.- // Facendo cosi' il ClusterContainer "cluster" contiene solo e sempre- // le foglie dell'albero creato dall'algoritmo TSE.+ // Update the appropriate ClusterContainer "clusters", by deleting+ // the cluster chosen and inserting the two newly created.+ // So ClusterContainer "cluster" only ever has+ // the leaves created by the algorithm TSE.Cluster *cluster = *itChoosedCluster;assert(cluster);@@ -603,7 +603,7 @@ void Cluster::computeCovariance() {statistic.covariance[i] = statistic.matrixR[i] - sumComponentsMatrix[i] / n;assert(!ISNAN(statistic.matrixR[i]));// assert(statistic.covariance[i] >= 0.0);- // instabilita' numerica ???+ // numerical instability???if (statistic.covariance[i] < 0.0) statistic.covariance[i] = 0.0;}}@@ -625,7 +625,7 @@ void Cluster::insert(ClusterElem *elem) {//------------------------------------------------------------------------------void Cluster::computeStatistics() {- // inizializza a zero la statistica del cluster+ // Initializes the cluster statistics.statistic.elemsCount = 0;statistic.sumCoords = TPoint(0, 0);@@ -635,7 +635,7 @@ void Cluster::computeStatistics() {for (i = 0; i < 9; ++i) statistic.matrixR[i] = 0.0;- // calcola la statistica del cluster+ // Compute cluster statistics.ClusterElemContainer::const_iterator it = data.begin();for (; it != data.end(); ++it) {const ClusterElem *elem = *it;@@ -657,17 +657,17 @@ void Cluster::computeStatistics() {#endif- // prima riga della matrice R+ // The first row of the matrix Rstatistic.matrixR[0] += r * r;statistic.matrixR[1] += r * g;statistic.matrixR[2] += r * b;- // seconda riga della matrice R+ // Second row of the matrix Rstatistic.matrixR[3] += r * g;statistic.matrixR[4] += g * g;statistic.matrixR[5] += g * b;- // terza riga della matrice R+ // The third row of the matrix Rstatistic.matrixR[6] += r * b;statistic.matrixR[7] += b * g;statistic.matrixR[8] += b * b;diff --git a/toonz/sources/common/tgeometry/tcurveutil.cpp b/toonz/sources/common/tgeometry/tcurveutil.cppindex 02820d619..87140c3e9 100644--- a/toonz/sources/common/tgeometry/tcurveutil.cpp+++ b/toonz/sources/common/tgeometry/tcurveutil.cpp@@ -8,14 +8,14 @@//=============================================================================/*-Questa funzione ritorna un vettore di-coppie di double (DoublePair) che individua i parametri-dei punti d'intersezione.+This function returns a vector of+pairs of double (DoublePair) which identifies the parameters+of the points of intersection.- L'intero restituito indica il numero d'intersezioni che- sono state individuate (per due segmenti una).+ The integer returned is the number of intersections which+ have been identified (for two segments).- Se i segmenti sono paralleli il parametro viene posto a -1.+ If the segments are parallel to the parameter it is set to -1.*/int intersect(const TSegment &first, const TSegment &second,@@ -97,9 +97,9 @@ int intersect(const TPointD &p1, const TPointD &p2, const TPointD &p3,return 1;}- // controllo che i segmenti non siano sulla stessa retta+ // Check that the segments are not on the same line.if (!cross(p2 - p1, p4 - p1)) {- // calcolo delle combinazioni baricentriche+ // Calculation of Barycentric combinations.double distp2p1 = norm2(p2 - p1);double distp3p4 = norm2(p3 - p4);@@ -110,7 +110,7 @@ int intersect(const TPointD &p1, const TPointD &p2, const TPointD &p3,int intersection = 0;- // calcolo delle prime due soluzioni+ // Calculation of the first two solutions.double vol1;if (distp3p4) {@@ -118,7 +118,7 @@ int intersect(const TPointD &p1, const TPointD &p2, const TPointD &p3,vol1 = (p1 - p3) * normalize(p4 - p3);- if (vol1 >= 0 && vol1 <= distp3p4) // combinazione baricentrica valida+ if (vol1 >= 0 && vol1 <= distp3p4) // Barycentric combinations valid{intersections.push_back(DoublePair(0.0, vol1 / distp3p4));++intersection;@@ -171,7 +171,7 @@ int intersect(const TQuadratic &c0, const TQuadratic &c1,std::vector<DoublePair> &intersections, bool checksegments) {int ret;- // funziona male, a volte toppa le intersezioni...+ // Works baddly, sometimes patch intersections...if (checksegments) {ret = intersectCloseControlPoints(c0, c1, intersections);if (ret != -2) return ret;@@ -281,12 +281,13 @@ int intersect(const TQuadratic &c0, const TQuadratic &c1,}//=============================================================================-// questa funzione verifica se il punto di controllo p1 e' molto vicino a p0 o a-// p2:-// in tal caso, si approssima la quadratica al segmento p0-p2.-// se p1 e' vicino a p0, la relazione che lega il t del segmento al t della-// quadratica originaria e' tq = sqrt(ts),-// se p1 e' vicino a p2, invece e' tq = 1-sqrt(1-ts).+// This function checks whether the control point+// p1 is very close to p0 or p2.+// In this case, we are approximated to the quadratic p0-p2 segment.+// If p1 is near p0, the relationship between the original and the quadratic segment:+// tq = sqrt(ts),+// If p1 is near p2, instead it's:+// tq = 1-sqrt(1-ts).int intersectCloseControlPoints(const TQuadratic &c0, const TQuadratic &c1,std::vector<DoublePair> &intersections) {@@ -304,7 +305,7 @@ int intersectCloseControlPoints(const TQuadratic &c0, const TQuadratic &c1,double val1 = std::max(dist3, dist4) / std::min(dist3, dist4);if (val0 > 1000000 &&- val1 > 1000000) // entrambe c0 e c1 approssimate a segmenti+ val1 > 1000000) // both c0 and c1 approximated by segments{TSegment s0 = TSegment(c0.getP0(), c0.getP2());TSegment s1 = TSegment(c1.getP0(), c1.getP2());@@ -319,7 +320,7 @@ int intersectCloseControlPoints(const TQuadratic &c0, const TQuadratic &c1,: 1 - sqrt(1 - intersections[i].second);}// return ret;- } else if (val0 > 1000000) // solo c0 approssimata a segmento+ } else if (val0 > 1000000) // c0 only approximated segment{TSegment s0 = TSegment(c0.getP0(), c0.getP2());ret = intersect(s0, c1, intersections);@@ -329,7 +330,7 @@ int intersectCloseControlPoints(const TQuadratic &c0, const TQuadratic &c1,? sqrt(intersections[i].first): 1 - sqrt(1 - intersections[i].first);// return ret;- } else if (val1 > 1000000) // solo c1 approssimata a segmento+ } else if (val1 > 1000000) // only c1 approximated segment{TSegment s1 = TSegment(c1.getP0(), c1.getP2());ret = intersect(c0, s1, intersections);@@ -363,7 +364,7 @@ int intersect(const TQuadratic &q, const TSegment &s,std::vector<DoublePair> &intersections, bool firstIsQuad) {int solutionNumber = 0;- // nota la retta a*x+b*y+c = 0 andiamo alla ricerca delle soluzioni+ // Note the line `a*x+b*y+c = 0` we search for solutions// di a*x(t)+b*y(t)+c=0 in [0,1]double a = s.getP0().y - s.getP1().y, b = s.getP1().x - s.getP0().x,c = -(a * s.getP0().x + b * s.getP0().y);@@ -383,7 +384,7 @@ int intersect(const TQuadratic &q, const TSegment &s,}if (q.getP2() - q.getP1() ==- q.getP1() - q.getP0()) { // pure il secondo e' unsegmento....+ q.getP1() - q.getP0()) { // the second is a segment....if (firstIsQuad)return intersect(TSegment(q.getP0(), q.getP2()), s, intersections);else