Skip to content

Commit 5e54e1c

Browse files
committed
docs
1 parent 578221b commit 5e54e1c

File tree

8 files changed

+46
-10
lines changed

8 files changed

+46
-10
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525
jobs:
2626
include:
2727
- stage: "Documentation"
28-
julia: 1.4
28+
julia: 1.5
2929
os: osx
3030
script:
3131
- julia --project=docs/ -e 'using Pkg; Pkg.instantiate();

CHANGELOG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Changelog
22

3-
## [v0.5.0] - forthcoming
3+
## [v0.5.0] - 2020-01-31
44

55
### Added
66

77
- dependency on Rotations.jl added
88

99
### Changed
1010

11-
- Point3D are now FieldVectors from StaticArrays.jl
11+
- Point3Ds are now FieldVectors from StaticArrays.jl
1212
- rotations now calculated by Rotations.jl
13-
- rotateby functions modified
13+
- all `rotateby` functions modified
1414

1515
### Removed
1616

docs/Project.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc"
66

77
[compat]
88
Documenter = "0.25"
9+
Rotations = "1"

docs/src/tools.md

+2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ sphericaltocartesian
314314
cartesiantospherical
315315
316316
dotproduct3D
317+
crossproduct3D
317318
magnitude
318319
anglebetweenvectors
319320
surfacenormal
321+
pointsperpendicular
320322
```

src/Point3D.jl

+7-3
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,16 @@ end
106106
"""
107107
anglebetweenvectors(v1::Point3D, v2::Point3D)
108108
109-
Calclates anglebetweenvectors
109+
Calclate the angle between two vectors.
110110
"""
111111
function anglebetweenvectors(v1::Point3D, v2::Point3D)
112112
intermediate = dotproduct3D(v1, v2)/(magnitude(v1) * magnitude(v2))
113113
# avoid domain errors
114-
return acos(min(max(-1, intermediate), 1))
114+
if isnan(intermediate)
115+
return 0.0
116+
else
117+
return acos(min(max(-1, intermediate), 1))
118+
end
115119
end
116120

117121
"""
@@ -127,7 +131,7 @@ end
127131
"""
128132
sphericaltocartesian(rho, theta, phi)
129133
130-
Return Point3D(x, y, z) of (rho, theta, phi).
134+
Return `Point3D(x, y, z)` corresponding to `(rho, theta, phi)`.
131135
"""
132136
function sphericaltocartesian(rho, theta, phi)
133137
x = rho * sin(phi) * cos(theta)

src/Thebes.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ using Luxor
44
using StaticArrays
55
using Rotations
66

7-
include("utils.jl")
87
include("Point3D.jl")
8+
include("utils.jl")
99
include("Projection.jl")
1010
include("Object.jl")
1111
include("pin.jl")
@@ -34,7 +34,7 @@ export project, Projection, newprojection,
3434
scaleby!, sortfaces!,
3535
sphericaltocartesian, cartesiantospherical,
3636
dotproduct3D, magnitude, anglebetweenvectors,
37-
surfacenormal, face,
37+
surfacenormal, face, crossproduct3D, pointsperpendicular,
3838

3939
text3D
4040

src/text.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Draw text at point `pt`, lying in the plane of the x axis.
99
Angles in `rotation` rotate the text about the `about` point,
1010
defaulting to `Point3D(0, 0, 0)`.
1111
12-
Uses current `fontface()` and `fontsize()` settings.
12+
Uses Luxor's `fontface()` and `fontsize()` settings.
1313
1414
Specify rotations using functions from Rotations.jl, such as:
1515

src/utils.jl

+29
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,32 @@ function carpet(n=100; kind=:circular)
117117
end
118118
end
119119
end
120+
121+
"""
122+
crossproduct3D(A::Point3D, B::Point3D)
123+
124+
Find one of these.
125+
"""
126+
function crossproduct3D(A::Point3D, B::Point3D)
127+
x = (A.y * B.z) - (A.z * B.y)
128+
y = (A.z * B.x) - (A.x * B.z)
129+
z = (A.x * B.y) - (A.y * B.x)
130+
return Point3D(x, y, z)
131+
end
132+
133+
"""
134+
pointsperpendicular(p1::Point3D, p2::Point3D, radius, angles = [0, π])
135+
136+
Find points perpendicular to a line joining p1 and p2.
137+
Points are `radius` units away from the line.
138+
"""
139+
function pointsperpendicular(p1::Point3D, p2::Point3D, radius, angles = [0, π])
140+
V3 = p2 - p1 # unit vector
141+
V3 /= distance(Point3D(0.0, 0.0, 0.0), V3)
142+
e = Point3D(0.0, 0.0, 1.0)
143+
V1 = crossproduct3D(e, V3) # unit vector perpendicular to both e and V3
144+
V1 /= distance(Point3D(0.0, 0.0, 0.0), V1)
145+
V2 = crossproduct3D(V3, V1) # third unit vector perpendicular to both V3 and V1
146+
# find points P on the circle θ radians relative to vector V1 (x-axis)
147+
return [p1 + radius * (cos(θ) * V1 + sin(θ) * V2) for θ in angles]
148+
end

0 commit comments

Comments
 (0)