-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from PRIME-TU-Delft/yustarandomname-complex-n…
…umbers complex numbers applet
- Loading branch information
Showing
24 changed files
with
433 additions
and
127 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -22,3 +22,4 @@ vite.config.ts.timestamp-* | |
build-* | ||
|
||
**/*.log | ||
chromatic.log |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,38 @@ | ||
<script lang="ts"> | ||
import { LINE_WIDTH } from '$lib/utils/AttributeDimensions'; | ||
import { PrimeColor } from '$lib/utils/PrimeColors'; | ||
import { arc, symbol, symbolTriangle } from 'd3'; | ||
import { Vector2 } from 'three'; | ||
export let color: PrimeColor = PrimeColor.black; | ||
export let startAngle = 0; | ||
export let endAngle = 0; | ||
export let origin = new Vector2(0, 0); | ||
export let width = LINE_WIDTH; | ||
export let distance = 0.8; | ||
export let hasHead = false; | ||
$: d = arc()({ | ||
innerRadius: distance - width / 2, | ||
outerRadius: distance + width / 2, | ||
startAngle: startAngle + Math.PI / 2, | ||
endAngle: endAngle + Math.PI / 2 | ||
}); | ||
const triangle = symbol() | ||
.type(symbolTriangle) | ||
.size(2 * width)(); | ||
</script> | ||
|
||
<g transform="translate({origin.x},{origin.y})"> | ||
<path {d} fill={color} /> | ||
</g> | ||
|
||
{#if hasHead} | ||
<g | ||
transform="rotate({(endAngle / Math.PI) * | ||
180}) translate({distance}, 0) rotate(180) translate(0, {2 * Math.PI * width})" | ||
> | ||
<path transform="" d={triangle} fill={color} /> | ||
</g> | ||
{/if} |
This file contains 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 |
---|---|---|
@@ -1,27 +1,46 @@ | ||
<script lang="ts"> | ||
import { Vector2 } from 'three'; | ||
import { PrimeColor } from '$lib/utils/PrimeColors'; | ||
import { arc } from 'd3'; | ||
import { arc, symbol, symbolTriangle } from 'd3'; | ||
import { LINE_WIDTH } from '$lib/utils/AttributeDimensions'; | ||
export let color: PrimeColor = PrimeColor.black; | ||
export let points: [Vector2, Vector2] = [new Vector2(1, 0), new Vector2(0, 1)]; | ||
export let origin = new Vector2(0, 0); | ||
export let width = LINE_WIDTH; | ||
export let distance = 0.8; | ||
export let hasHead = false; | ||
$: startAngle = points[0].angle(); | ||
$: endAngle = points[1].angle(); | ||
$: startAngle = Math.PI / 2 + points[0].angle(); | ||
$: endAngle = Math.PI / 2 + points[1].angle(); | ||
$: endPosition = points[1].clone().normalize().multiplyScalar(distance); | ||
$: angleDelta = endAngle - startAngle; | ||
$: adjustedStartAngle = angleDelta < -Math.PI ? startAngle + 2 * Math.PI : startAngle; | ||
$: adjustedEndAngle = angleDelta < -Math.PI ? endAngle + 2 * Math.PI : endAngle; | ||
$: headAngle = (adjustedEndAngle / Math.PI) * 180 + 90 + (angleDelta < 0 ? 180 : 0); | ||
// Arc defined by D3 | ||
$: d = arc()({ | ||
innerRadius: distance - width / 2, | ||
outerRadius: distance + width / 2, | ||
startAngle: Math.PI / 2 + startAngle, | ||
endAngle: Math.PI / 2 + endAngle | ||
startAngle: adjustedStartAngle, | ||
endAngle: adjustedEndAngle | ||
}); | ||
const triangle = symbol().type(symbolTriangle).size(0.3)(); | ||
</script> | ||
|
||
<g transform="translate({origin.x},{origin.y})"> | ||
<path {d} fill={color} /> | ||
</g> | ||
|
||
{#if hasHead} | ||
<g transform="translate({endPosition.x}, {endPosition.y})"> | ||
<path | ||
transform="rotate({headAngle}) scale({LINE_WIDTH * 15}) translate({0}, {LINE_WIDTH * 15})" | ||
d={triangle} | ||
fill={color} | ||
/> | ||
</g> | ||
{/if} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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,17 @@ | ||
<script lang="ts"> | ||
import type { Vector2 } from 'three'; | ||
export let points: [Vector2, Vector2, Vector2]; | ||
export let color: string = 'black'; | ||
export let strokeWidth: number = 1; | ||
$: [a, b, c] = points.map((p) => p.toArray().join(',')); | ||
$: d = points[1].clone().add(points[2]).sub(points[0]).toArray().join(','); | ||
</script> | ||
|
||
<!-- @component | ||
This component is used to draw a parallelogram in 2D. It needs three points to be defined and will automatically calculate the fourth point. | ||
--> | ||
|
||
<polygon fill={color} stroke="black" stroke-width={strokeWidth * 0.05} points="{a} {b} {d} {c} " /> |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.