| 155 | } |
| 156 | |
| 157 | Vector3D Transform::mapCartesianToType(QPointF point, const DatapickerImage::ReferencePoints& axisPoints) const { |
| 158 | switch (axisPoints.type) { |
| 159 | case DatapickerImage::GraphType::Linear: |
| 160 | return Vector3D(point.x(), point.y(), 0); |
| 161 | case DatapickerImage::GraphType::LnXY: |
| 162 | return Vector3D(exp(point.x()), exp(point.y()), 0); |
| 163 | case DatapickerImage::GraphType::LnX: |
| 164 | return Vector3D(exp(point.x()), point.y(), 0); |
| 165 | case DatapickerImage::GraphType::LnY: |
| 166 | return Vector3D(point.x(), exp(point.y()), 0); |
| 167 | case DatapickerImage::GraphType::Log10XY: |
| 168 | return Vector3D(pow(10, point.x()), pow(10, point.y()), 0); |
| 169 | case DatapickerImage::GraphType::Log10X: |
| 170 | return Vector3D(pow(10, point.x()), point.y(), 0); |
| 171 | case DatapickerImage::GraphType::Log10Y: |
| 172 | return Vector3D(point.x(), pow(10, point.y()), 0); |
| 173 | case DatapickerImage::GraphType::PolarInDegree: { |
| 174 | double r = sqrt(point.x() * point.x() + point.y() * point.y()); |
| 175 | double angle = atan(point.y() / point.x()) * M_180_PI; |
| 176 | return Vector3D(r, angle, 0); |
| 177 | } |
| 178 | case DatapickerImage::GraphType::PolarInRadians: { |
| 179 | double r = sqrt(point.x() * point.x() + point.y() * point.y()); |
| 180 | double angle = atan(point.y() / point.x()); |
| 181 | return Vector3D(r, angle, 0); |
| 182 | } |
| 183 | case DatapickerImage::GraphType::Ternary: { |
| 184 | double c = (point.y() * 2 * axisPoints.ternaryScale) / M_SQRT3; |
| 185 | double b = (point.x() * 2 * axisPoints.ternaryScale - c) / 2; |
| 186 | double a = axisPoints.ternaryScale - b - c; |
| 187 | return Vector3D(a, b, c); |
| 188 | } |
| 189 | } |
| 190 | return Vector3D(point.x(), point.y(), 0); // should never happen |
| 191 | } |