math.polar.d.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. import type { DeepImmutable } from "../types";
  2. import { Vector2, Vector3 } from "./math.vector";
  3. /**
  4. * Class used to store (r, theta) vector representation
  5. */
  6. export declare class Polar {
  7. radius: number;
  8. theta: number;
  9. /**
  10. * Creates a new Polar object
  11. * @param radius the radius of the vector
  12. * @param theta the angle of the vector
  13. */
  14. constructor(radius: number, theta: number);
  15. /**
  16. * Gets the class name
  17. * @returns the string "Polar"
  18. */
  19. getClassName(): string;
  20. /**
  21. * Converts the current polar to a string
  22. * @returns the current polar as a string
  23. */
  24. toString(): string;
  25. /**
  26. * Converts the current polar to an array
  27. * @returns the current polar as an array
  28. */
  29. asArray(): number[];
  30. /**
  31. * Adds the current Polar and the given Polar and stores the result
  32. * @param polar the polar to add
  33. * @param ref the polar to store the result in
  34. * @returns the updated ref
  35. */
  36. addToRef(polar: Polar, ref: Polar): Polar;
  37. /**
  38. * Adds the current Polar and the given Polar
  39. * @param polar the polar to add
  40. * @returns the sum polar
  41. */
  42. add(polar: Polar): Polar;
  43. /**
  44. * Adds the given polar to the current polar
  45. * @param polar the polar to add
  46. * @returns the current polar
  47. */
  48. addInPlace(polar: Polar): this;
  49. /**
  50. * Adds the provided values to the current polar
  51. * @param radius the amount to add to the radius
  52. * @param theta the amount to add to the theta
  53. * @returns the current polar
  54. */
  55. addInPlaceFromFloats(radius: number, theta: number): this;
  56. /**
  57. * Subtracts the given Polar from the current Polar and stores the result
  58. * @param polar the polar to subtract
  59. * @param ref the polar to store the result in
  60. * @returns the updated ref
  61. */
  62. subtractToRef(polar: Polar, ref: Polar): Polar;
  63. /**
  64. * Subtracts the given Polar from the current Polar
  65. * @param polar the polar to subtract
  66. * @returns the difference polar
  67. */
  68. subtract(polar: Polar): Polar;
  69. /**
  70. * Subtracts the given Polar from the current Polar
  71. * @param polar the polar to subtract
  72. * @returns the current polar
  73. */
  74. subtractInPlace(polar: Polar): this;
  75. /**
  76. * Subtracts the given floats from the current polar
  77. * @param radius the amount to subtract from the radius
  78. * @param theta the amount to subtract from the theta
  79. * @param ref the polar to store the result in
  80. * @returns the updated ref
  81. */
  82. subtractFromFloatsToRef(radius: number, theta: number, ref: Polar): Polar;
  83. /**
  84. * Subtracts the given floats from the current polar
  85. * @param radius the amount to subtract from the radius
  86. * @param theta the amount to subtract from the theta
  87. * @returns the difference polar
  88. */
  89. subtractFromFloats(radius: number, theta: number): Polar;
  90. /**
  91. * Multiplies the given Polar with the current Polar and stores the result
  92. * @param polar the polar to multiply
  93. * @param ref the polar to store the result in
  94. * @returns the updated ref
  95. */
  96. multiplyToRef(polar: Polar, ref: Polar): Polar;
  97. /**
  98. * Multiplies the given Polar with the current Polar
  99. * @param polar the polar to multiply
  100. * @returns the product polar
  101. */
  102. multiply(polar: Polar): Polar;
  103. /**
  104. * Multiplies the given Polar with the current Polar
  105. * @param polar the polar to multiply
  106. * @returns the current polar
  107. */
  108. multiplyInPlace(polar: Polar): this;
  109. /**
  110. * Divides the current Polar by the given Polar and stores the result
  111. * @param polar the polar to divide
  112. * @param ref the polar to store the result in
  113. * @returns the updated ref
  114. */
  115. divideToRef(polar: Polar, ref: Polar): Polar;
  116. /**
  117. * Divides the current Polar by the given Polar
  118. * @param polar the polar to divide
  119. * @returns the quotient polar
  120. */
  121. divide(polar: Polar): Polar;
  122. /**
  123. * Divides the current Polar by the given Polar
  124. * @param polar the polar to divide
  125. * @returns the current polar
  126. */
  127. divideInPlace(polar: Polar): this;
  128. /**
  129. * Clones the current polar
  130. * @returns a clone of the current polar
  131. */
  132. clone(): Polar;
  133. /**
  134. * Copies the source polar into the current polar
  135. * @param source the polar to copy from
  136. * @returns the current polar
  137. */
  138. copyFrom(source: Polar): this;
  139. /**
  140. * Copies the given values into the current polar
  141. * @param radius the radius to use
  142. * @param theta the theta to use
  143. * @returns the current polar
  144. */
  145. copyFromFloats(radius: number, theta: number): this;
  146. /**
  147. * Scales the current polar and stores the result
  148. * @param scale defines the multiplication factor
  149. * @param ref where to store the result
  150. * @returns the updated ref
  151. */
  152. scaleToRef(scale: number, ref: Polar): Polar;
  153. /**
  154. * Scales the current polar and returns a new polar with the scaled coordinates
  155. * @param scale defines the multiplication factor
  156. * @returns the scaled polar
  157. */
  158. scale(scale: number): Polar;
  159. /**
  160. * Scales the current polar
  161. * @param scale defines the multiplication factor
  162. * @returns the current polar
  163. */
  164. scaleInPlace(scale: number): this;
  165. /**
  166. * Sets the values of the current polar
  167. * @param radius the new radius
  168. * @param theta the new theta
  169. * @returns the current polar
  170. */
  171. set(radius: number, theta: number): this;
  172. /**
  173. * Sets the values of the current polar
  174. * @param value the new values
  175. * @returns the current polar
  176. */
  177. setAll(value: number): this;
  178. /**
  179. * Gets the rectangular coordinates of the current Polar
  180. * @param ref the reference to assign the result
  181. * @returns the updated reference
  182. */
  183. toVector2ToRef(ref: Vector2): Vector2;
  184. /**
  185. * Gets the rectangular coordinates of the current Polar
  186. * @returns the rectangular coordinates
  187. */
  188. toVector2(): Vector2;
  189. /**
  190. * Converts a given Vector2 to its polar coordinates
  191. * @param v the Vector2 to convert
  192. * @param ref the reference to assign the result
  193. * @returns the updated reference
  194. */
  195. static FromVector2ToRef(v: Vector2, ref: Polar): Polar;
  196. /**
  197. * Converts a given Vector2 to its polar coordinates
  198. * @param v the Vector2 to convert
  199. * @returns a Polar
  200. */
  201. static FromVector2(v: Vector2): Polar;
  202. /**
  203. * Converts an array of floats to a polar
  204. * @param array the array to convert
  205. * @returns the converted polar
  206. */
  207. static FromArray(array: number[]): Polar;
  208. }
  209. /**
  210. * Class used for (radius, theta, phi) vector representation.
  211. */
  212. export declare class Spherical {
  213. radius: number;
  214. theta: number;
  215. phi: number;
  216. /**
  217. * Creates a new Spherical object from the given spherical coordinates
  218. * @param radius spherical radius
  219. * @param theta angle from positive y axis to radial line from 0 to PI (vertical)
  220. * @param phi angle from positive x axis measured anticlockwise from -PI to PI (horizontal)
  221. */
  222. constructor(radius: number, theta: number, phi: number);
  223. /**
  224. * Gets the class name
  225. * @returns the string "Spherical"
  226. */
  227. getClassName(): string;
  228. /**
  229. * Converts the current spherical to a string
  230. * @returns the current spherical as a string
  231. */
  232. toString(): string;
  233. /**
  234. * Converts the current spherical to an array
  235. * @returns the current spherical as an array
  236. */
  237. asArray(): number[];
  238. /**
  239. * Adds the current Spherical and the given Spherical and stores the result
  240. * @param spherical the spherical to add
  241. * @param ref the spherical to store the result in
  242. * @returns the updated ref
  243. */
  244. addToRef(spherical: Spherical, ref: Spherical): Spherical;
  245. /**
  246. * Adds the current Spherical and the given Spherical
  247. * @param spherical the spherical to add
  248. * @returns the sum spherical
  249. */
  250. add(spherical: Spherical): Spherical;
  251. /**
  252. * Adds the given spherical to the current spherical
  253. * @param spherical the spherical to add
  254. * @returns the current spherical
  255. */
  256. addInPlace(spherical: Spherical): this;
  257. /**
  258. * Adds the provided values to the current spherical
  259. * @param radius the amount to add to the radius
  260. * @param theta the amount to add to the theta
  261. * @param phi the amount to add to the phi
  262. * @returns the current spherical
  263. */
  264. addInPlaceFromFloats(radius: number, theta: number, phi: number): this;
  265. /**
  266. * Subtracts the given Spherical from the current Spherical and stores the result
  267. * @param spherical the spherical to subtract
  268. * @param ref the spherical to store the result in
  269. * @returns the updated ref
  270. */
  271. subtractToRef(spherical: Spherical, ref: Spherical): Spherical;
  272. /**
  273. * Subtracts the given Spherical from the current Spherical
  274. * @param spherical the spherical to subtract
  275. * @returns the difference spherical
  276. */
  277. subtract(spherical: Spherical): Spherical;
  278. /**
  279. * Subtracts the given Spherical from the current Spherical
  280. * @param spherical the spherical to subtract
  281. * @returns the current spherical
  282. */
  283. subtractInPlace(spherical: Spherical): this;
  284. /**
  285. * Subtracts the given floats from the current spherical
  286. * @param radius the amount to subtract from the radius
  287. * @param theta the amount to subtract from the theta
  288. * @param phi the amount to subtract from the phi
  289. * @param ref the spherical to store the result in
  290. * @returns the updated ref
  291. */
  292. subtractFromFloatsToRef(radius: number, theta: number, phi: number, ref: Spherical): Spherical;
  293. /**
  294. * Subtracts the given floats from the current spherical
  295. * @param radius the amount to subtract from the radius
  296. * @param theta the amount to subtract from the theta
  297. * @param phi the amount to subtract from the phi
  298. * @returns the difference spherical
  299. */
  300. subtractFromFloats(radius: number, theta: number, phi: number): Spherical;
  301. /**
  302. * Multiplies the given Spherical with the current Spherical and stores the result
  303. * @param spherical the spherical to multiply
  304. * @param ref the spherical to store the result in
  305. * @returns the updated ref
  306. */
  307. multiplyToRef(spherical: Spherical, ref: Spherical): Spherical;
  308. /**
  309. * Multiplies the given Spherical with the current Spherical
  310. * @param spherical the spherical to multiply
  311. * @returns the product spherical
  312. */
  313. multiply(spherical: Spherical): Spherical;
  314. /**
  315. * Multiplies the given Spherical with the current Spherical
  316. * @param spherical the spherical to multiply
  317. * @returns the current spherical
  318. */
  319. multiplyInPlace(spherical: Spherical): this;
  320. /**
  321. * Divides the current Spherical by the given Spherical and stores the result
  322. * @param spherical the spherical to divide
  323. * @param ref the spherical to store the result in
  324. * @returns the updated ref
  325. */
  326. divideToRef(spherical: Spherical, ref: Spherical): Spherical;
  327. /**
  328. * Divides the current Spherical by the given Spherical
  329. * @param spherical the spherical to divide
  330. * @returns the quotient spherical
  331. */
  332. divide(spherical: Spherical): Spherical;
  333. /**
  334. * Divides the current Spherical by the given Spherical
  335. * @param spherical the spherical to divide
  336. * @returns the current spherical
  337. */
  338. divideInPlace(spherical: Spherical): this;
  339. /**
  340. * Clones the current spherical
  341. * @returns a clone of the current spherical
  342. */
  343. clone(): Spherical;
  344. /**
  345. * Copies the source spherical into the current spherical
  346. * @param source the spherical to copy from
  347. * @returns the current spherical
  348. */
  349. copyFrom(source: Spherical): this;
  350. /**
  351. * Copies the given values into the current spherical
  352. * @param radius the radius to use
  353. * @param theta the theta to use
  354. * @param phi the phi to use
  355. * @returns the current spherical
  356. */
  357. copyFromFloats(radius: number, theta: number, phi: number): this;
  358. /**
  359. * Scales the current spherical and stores the result
  360. * @param scale defines the multiplication factor
  361. * @param ref where to store the result
  362. * @returns the updated ref
  363. */
  364. scaleToRef(scale: number, ref: Spherical): Spherical;
  365. /**
  366. * Scales the current spherical and returns a new spherical with the scaled coordinates
  367. * @param scale defines the multiplication factor
  368. * @returns the scaled spherical
  369. */
  370. scale(scale: number): Spherical;
  371. /**
  372. * Scales the current spherical
  373. * @param scale defines the multiplication factor
  374. * @returns the current spherical
  375. */
  376. scaleInPlace(scale: number): this;
  377. /**
  378. * Sets the values of the current spherical
  379. * @param radius the new radius
  380. * @param theta the new theta
  381. * @param phi the new phi
  382. * @returns the current spherical
  383. */
  384. set(radius: number, theta: number, phi: number): this;
  385. /**
  386. * Sets the values of the current spherical
  387. * @param value the new values
  388. * @returns the current spherical
  389. */
  390. setAll(value: number): this;
  391. /**
  392. * Assigns the rectangular coordinates of the current Spherical to a Vector3
  393. * @param ref the Vector3 to update
  394. * @returns the updated Vector3
  395. */
  396. toVector3ToRef(ref: Vector3): Vector3;
  397. /**
  398. * Gets a Vector3 from the current spherical coordinates
  399. * @returns the (x, y,z) form of the current Spherical
  400. */
  401. toVector3(): Vector3;
  402. /**
  403. * Assigns the spherical coordinates from a Vector3
  404. * @param vector the vector to convert
  405. * @param ref the Spherical to update
  406. * @returns the updated ref
  407. */
  408. static FromVector3ToRef(vector: DeepImmutable<Vector3>, ref: Spherical): Spherical;
  409. /**
  410. * Gets a Spherical from a Vector3
  411. * @param vector defines the vector in (x, y, z) coordinate space
  412. * @returns a new Spherical
  413. */
  414. static FromVector3(vector: DeepImmutable<Vector3>): Spherical;
  415. /**
  416. * Converts an array of floats to a spherical
  417. * @param array the array to convert
  418. * @returns the converted spherical
  419. */
  420. static FromArray(array: number[]): Spherical;
  421. }