UNPKG

react-native-circular-chart-current

Version:
35 lines (34 loc) 1.67 kB
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } import { Degree } from "../math"; import { Coordinate } from "./Coordinate"; // https://www.mathsisfun.com/polar-cartesian-coordinates.html export class PolarCoordinate extends Coordinate { constructor(_ref) { let { coordX, coordY, radius, angle } = _ref; super(); _defineProperty(this, "coordX", 0); _defineProperty(this, "coordY", 0); _defineProperty(this, "radius", 0); _defineProperty(this, "angle", 0); _defineProperty(this, "toCartesian", () => { const startAngle = this.angle - 90; const angleInRadians = new Degree(startAngle).toRadian(); return { x: this.coordX + this.radius * Math.cos(angleInRadians), y: this.coordY + this.radius * Math.sin(angleInRadians) }; }); this.coordX = coordX; this.coordY = coordY; this.angle = angle; this.radius = radius; } } //# sourceMappingURL=PolarCoordinate.js.map