1
0

Line3.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Line3 - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <h1 translate="no">Line3</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>An analytical line segment in 3D space represented by a start and end point.</p></div>
  16. </header>
  17. <article>
  18. <div class="container-overview">
  19. <h2>Constructor</h2>
  20. <h3 class="name name-method" id="Line3" translate="no">new <a href="#Line3">Line3</a><span class="signature">( start : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, end : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span> </h3>
  21. <div class="method">
  22. <div class="description">
  23. <p>Constructs a new line segment.</p>
  24. </div>
  25. <table class="params">
  26. <tbody>
  27. <tr>
  28. <td class="name">
  29. <strong>start</strong>
  30. </td>
  31. <td class="description last">
  32. <p>Start of the line segment.</p>
  33. <p>Default is <code>(0,0,0)</code>.</p>
  34. </td>
  35. </tr>
  36. <tr>
  37. <td class="name">
  38. <strong>end</strong>
  39. </td>
  40. <td class="description last">
  41. <p>End of the line segment.</p>
  42. <p>Default is <code>(0,0,0)</code>.</p>
  43. </td>
  44. </tr>
  45. </tbody>
  46. </table>
  47. </div>
  48. </div>
  49. <h2 class="subsection-title">Properties</h2>
  50. <div class="member">
  51. <h3 class="name" id="end" translate="no">.<a href="#end">end</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  52. <div class="description">
  53. <p>End of the line segment.</p>
  54. </div>
  55. </div>
  56. <div class="member">
  57. <h3 class="name" id="start" translate="no">.<a href="#start">start</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  58. <div class="description">
  59. <p>Start of the line segment.</p>
  60. </div>
  61. </div>
  62. <h2 class="subsection-title">Methods</h2>
  63. <h3 class="name name-method" id="applyMatrix4" translate="no">.<a href="#applyMatrix4">applyMatrix4</a><span class="signature">( matrix : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="Line3.html">Line3</a></span> </h3>
  64. <div class="method">
  65. <div class="description">
  66. <p>Applies a 4x4 transformation matrix to this line segment.</p>
  67. </div>
  68. <table class="params">
  69. <tbody>
  70. <tr>
  71. <td class="name">
  72. <strong>matrix</strong>
  73. </td>
  74. <td class="description last">
  75. <p>The transformation matrix.</p>
  76. </td>
  77. </tr>
  78. </tbody>
  79. </table>
  80. <dl class="details">
  81. <dt class="tag-returns"><strong>Returns:</strong> A reference to this line segment.</dt>
  82. </dl>
  83. </div>
  84. <h3 class="name name-method" id="at" translate="no">.<a href="#at">at</a><span class="signature">( t : <span class="param-type">number</span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  85. <div class="method">
  86. <div class="description">
  87. <p>Returns a vector at a certain position along the line segment.</p>
  88. </div>
  89. <table class="params">
  90. <tbody>
  91. <tr>
  92. <td class="name">
  93. <strong>t</strong>
  94. </td>
  95. <td class="description last">
  96. <p>A value between <code>[0,1]</code> to represent a position along the line segment.</p>
  97. </td>
  98. </tr>
  99. <tr>
  100. <td class="name">
  101. <strong>target</strong>
  102. </td>
  103. <td class="description last">
  104. <p>The target vector that is used to store the method's result.</p>
  105. </td>
  106. </tr>
  107. </tbody>
  108. </table>
  109. <dl class="details">
  110. <dt class="tag-returns"><strong>Returns:</strong> The delta vector.</dt>
  111. </dl>
  112. </div>
  113. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="Line3.html">Line3</a></span> </h3>
  114. <div class="method">
  115. <div class="description">
  116. <p>Returns a new line segment with copied values from this instance.</p>
  117. </div>
  118. <dl class="details">
  119. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  120. </dl>
  121. </div>
  122. <h3 class="name name-method" id="closestPointToPoint" translate="no">.<a href="#closestPointToPoint">closestPointToPoint</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, clampToLine : <span class="param-type">boolean</span>, target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  123. <div class="method">
  124. <div class="description">
  125. <p>Returns the closest point on the line for a given point.</p>
  126. </div>
  127. <table class="params">
  128. <tbody>
  129. <tr>
  130. <td class="name">
  131. <strong>point</strong>
  132. </td>
  133. <td class="description last">
  134. <p>The point to compute the closest point on the line for.</p>
  135. </td>
  136. </tr>
  137. <tr>
  138. <td class="name">
  139. <strong>clampToLine</strong>
  140. </td>
  141. <td class="description last">
  142. <p>Whether to clamp the result to the range <code>[0,1]</code> or not.</p>
  143. </td>
  144. </tr>
  145. <tr>
  146. <td class="name">
  147. <strong>target</strong>
  148. </td>
  149. <td class="description last">
  150. <p>The target vector that is used to store the method's result.</p>
  151. </td>
  152. </tr>
  153. </tbody>
  154. </table>
  155. <dl class="details">
  156. <dt class="tag-returns"><strong>Returns:</strong> The closest point on the line.</dt>
  157. </dl>
  158. </div>
  159. <h3 class="name name-method" id="closestPointToPointParameter" translate="no">.<a href="#closestPointToPointParameter">closestPointToPointParameter</a><span class="signature">( point : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, clampToLine : <span class="param-type">boolean</span> )</span><span class="type-signature"> : number</span> </h3>
  160. <div class="method">
  161. <div class="description">
  162. <p>Returns a point parameter based on the closest point as projected on the line segment.</p>
  163. </div>
  164. <table class="params">
  165. <tbody>
  166. <tr>
  167. <td class="name">
  168. <strong>point</strong>
  169. </td>
  170. <td class="description last">
  171. <p>The point for which to return a point parameter.</p>
  172. </td>
  173. </tr>
  174. <tr>
  175. <td class="name">
  176. <strong>clampToLine</strong>
  177. </td>
  178. <td class="description last">
  179. <p>Whether to clamp the result to the range <code>[0,1]</code> or not.</p>
  180. </td>
  181. </tr>
  182. </tbody>
  183. </table>
  184. <dl class="details">
  185. <dt class="tag-returns"><strong>Returns:</strong> The point parameter.</dt>
  186. </dl>
  187. </div>
  188. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( line : <span class="param-type"><a href="Line3.html">Line3</a></span> )</span><span class="type-signature"> : <a href="Line3.html">Line3</a></span> </h3>
  189. <div class="method">
  190. <div class="description">
  191. <p>Copies the values of the given line segment to this instance.</p>
  192. </div>
  193. <table class="params">
  194. <tbody>
  195. <tr>
  196. <td class="name">
  197. <strong>line</strong>
  198. </td>
  199. <td class="description last">
  200. <p>The line segment to copy.</p>
  201. </td>
  202. </tr>
  203. </tbody>
  204. </table>
  205. <dl class="details">
  206. <dt class="tag-returns"><strong>Returns:</strong> A reference to this line segment.</dt>
  207. </dl>
  208. </div>
  209. <h3 class="name name-method" id="delta" translate="no">.<a href="#delta">delta</a><span class="signature">( target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  210. <div class="method">
  211. <div class="description">
  212. <p>Returns the delta vector of the line segment's start and end point.</p>
  213. </div>
  214. <table class="params">
  215. <tbody>
  216. <tr>
  217. <td class="name">
  218. <strong>target</strong>
  219. </td>
  220. <td class="description last">
  221. <p>The target vector that is used to store the method's result.</p>
  222. </td>
  223. </tr>
  224. </tbody>
  225. </table>
  226. <dl class="details">
  227. <dt class="tag-returns"><strong>Returns:</strong> The delta vector.</dt>
  228. </dl>
  229. </div>
  230. <h3 class="name name-method" id="distance" translate="no">.<a href="#distance">distance</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  231. <div class="method">
  232. <div class="description">
  233. <p>Returns the Euclidean distance between the line' start and end point.</p>
  234. </div>
  235. <dl class="details">
  236. <dt class="tag-returns"><strong>Returns:</strong> The Euclidean distance.</dt>
  237. </dl>
  238. </div>
  239. <h3 class="name name-method" id="distanceSq" translate="no">.<a href="#distanceSq">distanceSq</a><span class="signature">()</span><span class="type-signature"> : number</span> </h3>
  240. <div class="method">
  241. <div class="description">
  242. <p>Returns the squared Euclidean distance between the line' start and end point.</p>
  243. </div>
  244. <dl class="details">
  245. <dt class="tag-returns"><strong>Returns:</strong> The squared Euclidean distance.</dt>
  246. </dl>
  247. </div>
  248. <h3 class="name name-method" id="distanceSqToLine3" translate="no">.<a href="#distanceSqToLine3">distanceSqToLine3</a><span class="signature">( line : <span class="param-type"><a href="Line3.html">Line3</a></span>, c1 : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, c2 : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : number</span> </h3>
  249. <div class="method">
  250. <div class="description">
  251. <p>Returns the closest squared distance between this line segment and the given one.</p>
  252. </div>
  253. <table class="params">
  254. <tbody>
  255. <tr>
  256. <td class="name">
  257. <strong>line</strong>
  258. </td>
  259. <td class="description last">
  260. <p>The line segment to compute the closest squared distance to.</p>
  261. </td>
  262. </tr>
  263. <tr>
  264. <td class="name">
  265. <strong>c1</strong>
  266. </td>
  267. <td class="description last">
  268. <p>The closest point on this line segment.</p>
  269. </td>
  270. </tr>
  271. <tr>
  272. <td class="name">
  273. <strong>c2</strong>
  274. </td>
  275. <td class="description last">
  276. <p>The closest point on the given line segment.</p>
  277. </td>
  278. </tr>
  279. </tbody>
  280. </table>
  281. <dl class="details">
  282. <dt class="tag-returns"><strong>Returns:</strong> The squared distance between this line segment and the given one.</dt>
  283. </dl>
  284. </div>
  285. <h3 class="name name-method" id="equals" translate="no">.<a href="#equals">equals</a><span class="signature">( line : <span class="param-type"><a href="Line3.html">Line3</a></span> )</span><span class="type-signature"> : boolean</span> </h3>
  286. <div class="method">
  287. <div class="description">
  288. <p>Returns <code>true</code> if this line segment is equal with the given one.</p>
  289. </div>
  290. <table class="params">
  291. <tbody>
  292. <tr>
  293. <td class="name">
  294. <strong>line</strong>
  295. </td>
  296. <td class="description last">
  297. <p>The line segment to test for equality.</p>
  298. </td>
  299. </tr>
  300. </tbody>
  301. </table>
  302. <dl class="details">
  303. <dt class="tag-returns"><strong>Returns:</strong> Whether this line segment is equal with the given one.</dt>
  304. </dl>
  305. </div>
  306. <h3 class="name name-method" id="getCenter" translate="no">.<a href="#getCenter">getCenter</a><span class="signature">( target : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  307. <div class="method">
  308. <div class="description">
  309. <p>Returns the center of the line segment.</p>
  310. </div>
  311. <table class="params">
  312. <tbody>
  313. <tr>
  314. <td class="name">
  315. <strong>target</strong>
  316. </td>
  317. <td class="description last">
  318. <p>The target vector that is used to store the method's result.</p>
  319. </td>
  320. </tr>
  321. </tbody>
  322. </table>
  323. <dl class="details">
  324. <dt class="tag-returns"><strong>Returns:</strong> The center point.</dt>
  325. </dl>
  326. </div>
  327. <h3 class="name name-method" id="set" translate="no">.<a href="#set">set</a><span class="signature">( start : <span class="param-type"><a href="Vector3.html">Vector3</a></span>, end : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="Line3.html">Line3</a></span> </h3>
  328. <div class="method">
  329. <div class="description">
  330. <p>Sets the start and end values by copying the given vectors.</p>
  331. </div>
  332. <table class="params">
  333. <tbody>
  334. <tr>
  335. <td class="name">
  336. <strong>start</strong>
  337. </td>
  338. <td class="description last">
  339. <p>The start point.</p>
  340. </td>
  341. </tr>
  342. <tr>
  343. <td class="name">
  344. <strong>end</strong>
  345. </td>
  346. <td class="description last">
  347. <p>The end point.</p>
  348. </td>
  349. </tr>
  350. </tbody>
  351. </table>
  352. <dl class="details">
  353. <dt class="tag-returns"><strong>Returns:</strong> A reference to this line segment.</dt>
  354. </dl>
  355. </div>
  356. <h2 class="subsection-title">Source</h2>
  357. <p>
  358. <a href="https://github.com/mrdoob/three.js/blob/master/src/math/Line3.js" translate="no" target="_blank" rel="noopener">src/math/Line3.js</a>
  359. </p>
  360. </article>
  361. </section>
  362. <script src="../scripts/linenumber.js"></script>
  363. <script src="../scripts/page.js"></script>
  364. </body>
  365. </html>
粤ICP备19079148号