-
Notifications
You must be signed in to change notification settings - Fork 0
New main: assigment 3 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kurtaga
wants to merge
8
commits into
new-main
Choose a base branch
from
dn03
base: new-main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d234e4c
Solved Dn01
kurtaga e4367f1
Dn02 implementation
kurtaga bc6bbd3
Updated dn01 report
kurtaga 09de411
Dn02 report written
kurtaga 60bf2ef
Fixed Gauss
kurtaga 99b05d1
Dn03 added few tests
kurtaga 53f7713
Dn03 implementation and report
kurtaga 4476075
Cleaned branch dn03
kurtaga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,291 @@ | ||
| # This file is machine-generated - editing it directly is not advised | ||
|
|
||
| julia_version = "1.11.5" | ||
| manifest_format = "2.0" | ||
| project_hash = "8df2b700e81f9e668d10509ce74d85cac1f042f2" | ||
|
|
||
| [[deps.ArgTools]] | ||
| uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" | ||
| version = "1.1.2" | ||
|
|
||
| [[deps.Artifacts]] | ||
| uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.Base64]] | ||
| uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.DataAPI]] | ||
| git-tree-sha1 = "abe83f3a2f1b857aac70ef8b269080af17764bbe" | ||
| uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" | ||
| version = "1.16.0" | ||
|
|
||
| [[deps.DataValueInterfaces]] | ||
| git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" | ||
| uuid = "e2d170a0-9d28-54be-80f0-106bbe20a464" | ||
| version = "1.0.0" | ||
|
|
||
| [[deps.Dates]] | ||
| deps = ["Printf"] | ||
| uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.DocStringExtensions]] | ||
| git-tree-sha1 = "7442a5dfe1ebb773c29cc2962a8980f47221d76c" | ||
| uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" | ||
| version = "0.9.5" | ||
|
|
||
| [[deps.Downloads]] | ||
| deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"] | ||
| uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" | ||
| version = "1.6.0" | ||
|
|
||
| [[deps.FileWatching]] | ||
| uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.Highlights]] | ||
| deps = ["DocStringExtensions", "InteractiveUtils", "REPL"] | ||
| git-tree-sha1 = "9e13b8d8b1367d9692a90ea4711b4278e4755c32" | ||
| uuid = "eafb193a-b7ab-5a9e-9068-77385905fa72" | ||
| version = "0.5.3" | ||
|
|
||
| [[deps.InteractiveUtils]] | ||
| deps = ["Markdown"] | ||
| uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.IteratorInterfaceExtensions]] | ||
| git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856" | ||
| uuid = "82899510-4779-5014-852e-03e436cf321d" | ||
| version = "1.0.0" | ||
|
|
||
| [[deps.JLLWrappers]] | ||
| deps = ["Artifacts", "Preferences"] | ||
| git-tree-sha1 = "0533e564aae234aff59ab625543145446d8b6ec2" | ||
| uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" | ||
| version = "1.7.1" | ||
|
|
||
| [[deps.JSON]] | ||
| deps = ["Dates", "Mmap", "Parsers", "Unicode"] | ||
| git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a" | ||
| uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" | ||
| version = "0.21.4" | ||
|
|
||
| [[deps.LibCURL]] | ||
| deps = ["LibCURL_jll", "MozillaCACerts_jll"] | ||
| uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" | ||
| version = "0.6.4" | ||
|
|
||
| [[deps.LibCURL_jll]] | ||
| deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] | ||
| uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" | ||
| version = "8.6.0+0" | ||
|
|
||
| [[deps.LibGit2]] | ||
| deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] | ||
| uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.LibGit2_jll]] | ||
| deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] | ||
| uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" | ||
| version = "1.7.2+0" | ||
|
|
||
| [[deps.LibSSH2_jll]] | ||
| deps = ["Artifacts", "Libdl", "MbedTLS_jll"] | ||
| uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" | ||
| version = "1.11.0+1" | ||
|
|
||
| [[deps.Libdl]] | ||
| uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.Libiconv_jll]] | ||
| deps = ["Artifacts", "JLLWrappers", "Libdl"] | ||
| git-tree-sha1 = "be484f5c92fad0bd8acfef35fe017900b0b73809" | ||
| uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" | ||
| version = "1.18.0+0" | ||
|
|
||
| [[deps.Logging]] | ||
| uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.Markdown]] | ||
| deps = ["Base64"] | ||
| uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.MbedTLS_jll]] | ||
| deps = ["Artifacts", "Libdl"] | ||
| uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" | ||
| version = "2.28.6+0" | ||
|
|
||
| [[deps.Mmap]] | ||
| uuid = "a63ad114-7e13-5084-954f-fe012c677804" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.MozillaCACerts_jll]] | ||
| uuid = "14a3606d-f60d-562e-9121-12d972cd8159" | ||
| version = "2023.12.12" | ||
|
|
||
| [[deps.Mustache]] | ||
| deps = ["Printf", "Tables"] | ||
| git-tree-sha1 = "3cbd5dda543bc59f2e482607ccf84b633724fc32" | ||
| uuid = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70" | ||
| version = "1.0.21" | ||
|
|
||
| [[deps.NetworkOptions]] | ||
| uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" | ||
| version = "1.2.0" | ||
|
|
||
| [[deps.OrderedCollections]] | ||
| git-tree-sha1 = "05868e21324cede2207c6f0f466b4bfef6d5e7ee" | ||
| uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" | ||
| version = "1.8.1" | ||
|
|
||
| [[deps.Parsers]] | ||
| deps = ["Dates", "PrecompileTools", "UUIDs"] | ||
| git-tree-sha1 = "7d2f8f21da5db6a806faf7b9b292296da42b2810" | ||
| uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" | ||
| version = "2.8.3" | ||
|
|
||
| [[deps.Pkg]] | ||
| deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "Random", "SHA", "TOML", "Tar", "UUIDs", "p7zip_jll"] | ||
| uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" | ||
| version = "1.11.0" | ||
| weakdeps = ["REPL"] | ||
|
|
||
| [deps.Pkg.extensions] | ||
| REPLExt = "REPL" | ||
|
|
||
| [[deps.PrecompileTools]] | ||
| deps = ["Preferences"] | ||
| git-tree-sha1 = "5aa36f7049a63a1528fe8f7c3f2113413ffd4e1f" | ||
| uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" | ||
| version = "1.2.1" | ||
|
|
||
| [[deps.Preferences]] | ||
| deps = ["TOML"] | ||
| git-tree-sha1 = "0f27480397253da18fe2c12a4ba4eb9eb208bf3d" | ||
| uuid = "21216c6a-2e73-6563-6e65-726566657250" | ||
| version = "1.5.0" | ||
|
|
||
| [[deps.Printf]] | ||
| deps = ["Unicode"] | ||
| uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.REPL]] | ||
| deps = ["InteractiveUtils", "Markdown", "Sockets", "StyledStrings", "Unicode"] | ||
| uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.Random]] | ||
| deps = ["SHA"] | ||
| uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.RelocatableFolders]] | ||
| deps = ["SHA", "Scratch"] | ||
| git-tree-sha1 = "ffdaf70d81cf6ff22c2b6e733c900c3321cab864" | ||
| uuid = "05181044-ff0b-4ac5-8273-598c1e38db00" | ||
| version = "1.0.1" | ||
|
|
||
| [[deps.Requires]] | ||
| deps = ["UUIDs"] | ||
| git-tree-sha1 = "62389eeff14780bfe55195b7204c0d8738436d64" | ||
| uuid = "ae029012-a4dd-5104-9daa-d747884805df" | ||
| version = "1.3.1" | ||
|
|
||
| [[deps.SHA]] | ||
| uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" | ||
| version = "0.7.0" | ||
|
|
||
| [[deps.Scratch]] | ||
| deps = ["Dates"] | ||
| git-tree-sha1 = "9b81b8393e50b7d4e6d0a9f14e192294d3b7c109" | ||
| uuid = "6c6a2e73-6563-6170-7368-637461726353" | ||
| version = "1.3.0" | ||
|
|
||
| [[deps.Serialization]] | ||
| uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.Sockets]] | ||
| uuid = "6462fe0b-24de-5631-8697-dd941f90decc" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.StringEncodings]] | ||
| deps = ["Libiconv_jll"] | ||
| git-tree-sha1 = "b765e46ba27ecf6b44faf70df40c57aa3a547dcb" | ||
| uuid = "69024149-9ee7-55f6-a4c4-859efe599b68" | ||
| version = "0.3.7" | ||
|
|
||
| [[deps.StyledStrings]] | ||
| uuid = "f489334b-da3d-4c2e-b8f0-e476e12c162b" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.TOML]] | ||
| deps = ["Dates"] | ||
| uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" | ||
| version = "1.0.3" | ||
|
|
||
| [[deps.TableTraits]] | ||
| deps = ["IteratorInterfaceExtensions"] | ||
| git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39" | ||
| uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c" | ||
| version = "1.0.1" | ||
|
|
||
| [[deps.Tables]] | ||
| deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "OrderedCollections", "TableTraits"] | ||
| git-tree-sha1 = "f2c1efbc8f3a609aadf318094f8fc5204bdaf344" | ||
| uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" | ||
| version = "1.12.1" | ||
|
|
||
| [[deps.Tar]] | ||
| deps = ["ArgTools", "SHA"] | ||
| uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" | ||
| version = "1.10.0" | ||
|
|
||
| [[deps.Test]] | ||
| deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] | ||
| uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.UUIDs]] | ||
| deps = ["Random", "SHA"] | ||
| uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.Unicode]] | ||
| uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" | ||
| version = "1.11.0" | ||
|
|
||
| [[deps.Weave]] | ||
| deps = ["Base64", "Dates", "Highlights", "JSON", "Markdown", "Mustache", "Pkg", "Printf", "REPL", "RelocatableFolders", "Requires", "Serialization", "YAML"] | ||
| git-tree-sha1 = "092217eb5443926d200ae9325f103906efbb68b1" | ||
| uuid = "44d3d7a6-8a23-5bf8-98c5-b353f8df5ec9" | ||
| version = "0.10.12" | ||
|
|
||
| [[deps.YAML]] | ||
| deps = ["Base64", "Dates", "Printf", "StringEncodings"] | ||
| git-tree-sha1 = "2f58ac39f64b41fb812340347525be3b590cce3b" | ||
| uuid = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" | ||
| version = "0.4.14" | ||
|
|
||
| [[deps.Zlib_jll]] | ||
| deps = ["Libdl"] | ||
| uuid = "83775a58-1f1d-513f-b197-d71354ab007a" | ||
| version = "1.2.13+1" | ||
|
|
||
| [[deps.nghttp2_jll]] | ||
| deps = ["Artifacts", "Libdl"] | ||
| uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" | ||
| version = "1.59.0+0" | ||
|
|
||
| [[deps.p7zip_jll]] | ||
| deps = ["Artifacts", "Libdl"] | ||
| uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" | ||
| version = "17.4.0+2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| name = "Dn03" | ||
| uuid = "a5399141-7ce7-45c1-aa92-90a6684ca4a8" | ||
| authors = ["Kurtaga <ak84795@student.uni-lj.si>"] | ||
| version = "0.1.0" | ||
|
|
||
| [deps] | ||
| Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
| Weave = "44d3d7a6-8a23-5bf8-98c5-b353f8df5ec9" | ||
|
|
||
| [compat] | ||
| Test = "1.11.0" | ||
| Weave = "0.10.12" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Curve Length for an Implicitly Defined Curve | ||
| **Alen Kurtagić** | ||
|
|
||
| # Implicit Curves | ||
| In many applications, explicit parametric equations of curves are either unknown or too complicated to work with. A common alternative is to describe a curve implicitly, for example as the intersection of two surfaces. | ||
|
|
||
| An implicit surface is defined by a function $F(x,y,z)$, with the surface itself given by the set of points where $F(x,y,z) = 0$. If two such surfaces are defined by | ||
| $F_1(x,y,z) = 0$ and $F_2(x,y,z) = 0$, their intersection is, in general, a curve in three-dimensional space. | ||
|
|
||
| The gradients | ||
| $$ | ||
| \nabla F_1, \quad \nabla F_2 | ||
| $$ | ||
| are normal vectors to the two surfaces. The tangent to the intersection curve must lie in both tangent planes simultaneously, and is therefore perpendicular to both normals. This tangent direction is obtained through the cross product: | ||
| $$ | ||
| \dot{\mathbf{x}}(t) = \nabla F_1(\mathbf{x}(t)) \times \nabla F_2(\mathbf{x}(t)). | ||
| $$ | ||
|
|
||
| This gives a differential equation that describes the motion of a point traveling along the curve. | ||
|
|
||
| Our specific case is the curve defined by | ||
| $$ | ||
| F_1(x, y, z) = x^4 + \tfrac{1}{2} y^2 + z^2 - 12 = 0, | ||
| $$ | ||
| $$ | ||
| F_2(x, y, z) = x^2 + y^2 - 4z^2 - 8 = 0. | ||
| $$ | ||
|
|
||
| Because no simple parametric form is available, we approximate this curve numerically by integrating the associated ODE and then use the trajectory to estimate its length. | ||
|
|
||
| # Integrating with Explicit Euler | ||
| We integrate the ODE using the explicit Euler method. Given a current point $u_k$ on the curve and step size $h$, the next point is computed as | ||
|
|
||
| $$ | ||
| u_{k+1} = u_k + h \, \frac{f(u_k)}{\|f(u_k)\|}, | ||
| $$ | ||
|
|
||
| where $f(u) = \nabla F_1(u) \times \nabla F_2(u)$. The normalization ensures each step moves along the tangent direction with fixed arc-length increment. | ||
|
|
||
| To detect closure of the curve, we monitor the distance back to the starting point $u_0$ and stop when $\|u_k - u_0\|$ is below a tolerance proportional to $h$. | ||
|
|
||
| ```julia | ||
| using Dn03 | ||
| using Plots | ||
|
|
||
| ∇F1(x, y, z) = [4x^3, y, 2z] | ||
| ∇F2(x, y, z) = [2x, 2y, -8z] | ||
|
|
||
| u0 = [1.758, 2.215, 0.0] | ||
| traj = Dn03.integrate_explicit_euler(u0, 1e-3, ∇F1, ∇F2) | ||
|
|
||
| # extract coordinates | ||
| xs = [p[1] for p in traj] | ||
| ys = [p[2] for p in traj] | ||
| zs = [p[3] for p in traj] | ||
|
|
||
| # plot | ||
| plot3d(xs, ys, zs, seriestype = :line, linewidth = 2, color = :blue, label = "Implicit curve") | ||
| ``` | ||
|
|
||
| # Curve Length | ||
| The algorithm produces a trajectory that traces the implicit intersection curve. The total arc length is approximated by summing distances between consecutive points. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kurtaga Given that you normalized the cross product, the parameter from the ODE will be the natural parameter on the curve. So there is no need to perform an additional sum. |
||
|
|
||
| For step size $h$, the length is approximately $L \approx N h$, where $N$ is the number of steps taken before closure. | ||
|
|
||
| ```julia | ||
| curve_length(traj) | ||
| ``` | ||
|
|
||
| In this case, the computed length is approximately 15.127 units. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kurtaga Explicit Euler method is order 1 and it needs orders of magnitude more calculations than higher order methods to achieve sufficient accuracy. The method used should be at least of order 4.