Libraryless. Click here for Pure Java version (8126L/45K).
// line that goes through x, y at specified angle // angle is in radians srecord LineThroughPoint(double x, double y, double angle) is G2Drawable { *(IDoublePt p, double *angle) { x = p.x_double(); y = p.y_double(); } DoublePt pointOnLine(double distance) { ret doublePt( x+sin(angle)*distance, y+cos(angle)*distance); } // uses color selected in g public void drawOn(Graphics2D g) { int distance = 200; DoublePt p1 = pointOnLine(-distance); DoublePt p2 = pointOnLine(distance); g.drawLine( iround(p1.x_double()), iround(p1.y_double()), iround(p2.x_double()), iround(p2.y_double())); } }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1035464 |
| Snippet name: | LineThroughPoint |
| Eternal ID of this version: | #1035464/4 |
| Text MD5: | fbcb7889339e98f5b52b823e691a4161 |
| Transpilation MD5: | caa4ca8000c40c625120a03e63cb43af |
| Author: | stefan |
| Category: | javax / math |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-05-21 18:41:52 |
| Source code size: | 682 bytes / 24 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 567 / 676 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |