MCPcopy Create free account
hub / github.com/KDE/labplot / mapCartesianToType

Method mapCartesianToType

src/backend/datapicker/Transform.cpp:157–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157Vector3D 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}

Callers 9

mapCartesianToLinearMethod · 0.80
mapCartesianToLnXMethod · 0.80
mapCartesianToLnYMethod · 0.80
mapCartesianToLnXYMethod · 0.80
mapCartesianToLog10XMethod · 0.80
mapCartesianToLog10YMethod · 0.80
mapCartesianToLog10XYMethod · 0.80

Calls 3

Vector3DClass · 0.85
xMethod · 0.80
yMethod · 0.45

Tested by 9

mapCartesianToLinearMethod · 0.64
mapCartesianToLnXMethod · 0.64
mapCartesianToLnYMethod · 0.64
mapCartesianToLnXYMethod · 0.64
mapCartesianToLog10XMethod · 0.64
mapCartesianToLog10YMethod · 0.64
mapCartesianToLog10XYMethod · 0.64