Skip to content

Commit

Permalink
Fix radius1 of some predefined shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
gha3mi committed Apr 18, 2024
1 parent a2aa9aa commit 4ff6354
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 96 deletions.
14 changes: 7 additions & 7 deletions src/forcad_nurbs_curve.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1145,13 +1145,13 @@ pure subroutine set_circle(this, center, radius)

! Define control points for circle
allocate(Xc(7, 3))
Xc(1,:)= [ 1.0_rk/2.0_rk, 0.0_rk, 0.0_rk]
Xc(2,:)= [ 1.0_rk/2.0_rk, sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(3,:)= [-0.5_rk/2.0_rk, sqrt(3.0_rk)/4.0_rk, 0.0_rk]
Xc(4,:)= [-2.0_rk/2.0_rk, 0.0_rk, 0.0_rk]
Xc(5,:)= [-0.5_rk/2.0_rk, -sqrt(3.0_rk)/4.0_rk, 0.0_rk]
Xc(6,:)= [ 1.0_rk/2.0_rk, -sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(7,:)= [ 1.0_rk/2.0_rk, 0.0_rk, 0.0_rk]
Xc(1,:)= [ 1.0_rk, 0.0_rk, 0.0_rk]
Xc(2,:)= [ 1.0_rk, sqrt(3.0_rk), 0.0_rk]
Xc(3,:)= [-0.5_rk, sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(4,:)= [-2.0_rk, 0.0_rk, 0.0_rk]
Xc(5,:)= [-0.5_rk, -sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(6,:)= [ 1.0_rk, -sqrt(3.0_rk), 0.0_rk]
Xc(7,:)= [ 1.0_rk, 0.0_rk, 0.0_rk]

! Scale and translate the control points
do i = 1, size(Xc, 1)
Expand Down
70 changes: 38 additions & 32 deletions src/forcad_nurbs_surface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1919,27 +1919,29 @@ pure subroutine set_ring(this, center, radius1, radius2)

! Define control points for ring
allocate(Xc(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[ 1.0_rk, 0.0_rk, 0.0_rk]
Xc(9,:) = [ 1.0_rk, sqrt(3.0_rk), 0.0_rk]
Xc(10,:)= [-0.5_rk, sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(11,:)= [-2.0_rk, 0.0_rk, 0.0_rk]
Xc(12,:)= [-0.5_rk, -sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(13,:)= [ 1.0_rk, -sqrt(3.0_rk), 0.0_rk]
Xc(14,:)= [ 1.0_rk, 0.0_rk, 0.0_rk]

Xc(8:14,1:2) = Xc(8:14,1:2) * radius2

! Scale and translate the control points
! Translate the control points
do i = 1, size(Xc, 1)
Xc(i,:) = center + Xc(i,:) * radius1
Xc(i,:) = center + Xc(i,:)
end do

! Define weights for the control points
Expand Down Expand Up @@ -1968,23 +1970,25 @@ pure subroutine set_C(this, center, radius1, radius2)

! Define control points for C-shape
allocate(Xc(10, 3))
Xc(1,:)= [ 1.0_rk/2.0_rk, 0.0_rk, 0.0_rk]
Xc(2,:)= [ 1.0_rk/2.0_rk, sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(3,:)= [-0.5_rk/2.0_rk, sqrt(3.0_rk)/4.0_rk, 0.0_rk]
Xc(4,:)= [-2.0_rk/2.0_rk, 0.0_rk, 0.0_rk]
Xc(5,:)= [-0.5_rk/2.0_rk, -sqrt(3.0_rk)/4.0_rk, 0.0_rk]

Xc(6,:)= [ 1.0_rk/2.0_rk, 0.0_rk, 0.0_rk]
Xc(7,:)= [ 1.0_rk/2.0_rk, sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(8,:)= [-0.5_rk/2.0_rk, sqrt(3.0_rk)/4.0_rk, 0.0_rk]
Xc(9,:)= [-2.0_rk/2.0_rk, 0.0_rk, 0.0_rk]
Xc(10,:)=[-0.5_rk/2.0_rk, -sqrt(3.0_rk)/4.0_rk, 0.0_rk]
Xc(1,:)= [ 1.0_rk, 0.0_rk, 0.0_rk]
Xc(2,:)= [ 1.0_rk, sqrt(3.0_rk), 0.0_rk]
Xc(3,:)= [-0.5_rk, sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(4,:)= [-2.0_rk, 0.0_rk, 0.0_rk]
Xc(5,:)= [-0.5_rk, -sqrt(3.0_rk)/2.0_rk, 0.0_rk]

Xc(1:5,1:2) = Xc(1:5,1:2) * radius1

Xc(6,:)= [ 1.0_rk, 0.0_rk, 0.0_rk]
Xc(7,:)= [ 1.0_rk, sqrt(3.0_rk), 0.0_rk]
Xc(8,:)= [-0.5_rk, sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(9,:)= [-2.0_rk, 0.0_rk, 0.0_rk]
Xc(10,:)=[-0.5_rk, -sqrt(3.0_rk)/2.0_rk, 0.0_rk]

Xc(6:10,1:2) = Xc(6:10,1:2) * radius2

! Scale and translate the control points
! Translate the control points
do i = 1, size(Xc, 1)
Xc(i,:) = center + Xc(i,:) * radius1
Xc(i,:) = center + Xc(i,:)
end do

! Define weights for the control points
Expand Down Expand Up @@ -2019,6 +2023,8 @@ pure subroutine set_half_ring(this, center, radius1, radius2)
Xc(4,:) = [-0.5_rk, 0.5_rk, 0.0_rk]
Xc(5,:) = [-0.5_rk, 0.0_rk, 0.0_rk]

Xc(1:5,1:2) = Xc(1:5,1:2) * radius1

Xc(6,:) = [ 0.5_rk, 0.0_rk, 0.0_rk]
Xc(7,:) = [ 0.5_rk, 0.5_rk, 0.0_rk]
Xc(8,:) = [ 0.0_rk, 0.5_rk, 0.0_rk]
Expand All @@ -2027,9 +2033,9 @@ pure subroutine set_half_ring(this, center, radius1, radius2)

Xc(6:10,1:2) = Xc(6:10,1:2) * radius2

! Scale and translate the control points
! Translate the control points
do i = 1, size(Xc, 1)
Xc(i,:) = center + Xc(i,:) * radius1
Xc(i,:) = center + Xc(i,:)
end do

! Define weights for the control points
Expand Down
126 changes: 69 additions & 57 deletions src/forcad_nurbs_volume.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2357,45 +2357,49 @@ pure sub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0.0_rk]

Xc(1:7,1:2) = Xc(1:7,1:2) * radius1

Xc(8,:) = [ 1.0_rk, 0.0_rk, 0.0_rk]
Xc(9,:) = [ 1.0_rk, sqrt(3.0_rk), 0.0_rk]
Xc(10,:)= [-0.5_rk, sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(11,:)= [-2.0_rk, 0.0_rk, 0.0_rk]
Xc(12,:)= [-0.5_rk, -sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(13,:)= [ 1.0_rk, -sqrt(3.0_rk), 0.0_rk]
Xc(14,:)= [ 1.0_rk, 0.0_rk, 0.0_rk]

Xc(8:14,1:2) = Xc(8:14,1:2) * radius2

Xc(15,:)= [ 1.0_rk/2.0_rk, 0.0_rk, length]
Xc(16,:)= [ 1.0_rk/2.0_rk, sqrt(3.0_rk)/2.0_rk, length]
Xc(17,:)= [-0.5_rk/2.0_rk, sqrt(3.0_rk)/4.0_rk, length]
Xc(18,:)= [-2.0_rk/2.0_rk, 0.0_rk, length]
Xc(19,:)= [-0.5_rk/2.0_rk, -sqrt(3.0_rk)/4.0_rk, length]
Xc(20,:)= [ 1.0_rk/2.0_rk, -sqrt(3.0_rk)/2.0_rk, length]
Xc(21,:)= [ 1.0_rk/2.0_rk, 0.0_rk, length]

Xc(22,:)= [ 1.0_rk/2.0_rk, 0.0_rk, length]
Xc(23,:)= [ 1.0_rk/2.0_rk, sqrt(3.0_rk)/2.0_rk, length]
Xc(24,:)= [-0.5_rk/2.0_rk, sqrt(3.0_rk)/4.0_rk, length]
Xc(25,:)= [-2.0_rk/2.0_rk, 0.0_rk, length]
Xc(26,:)= [-0.5_rk/2.0_rk, -sqrt(3.0_rk)/4.0_rk, length]
Xc(27,:)= [ 1.0_rk/2.0_rk, -sqrt(3.0_rk)/2.0_rk, length]
Xc(28,:)= [ 1.0_rk/2.0_rk, 0.0_rk, length]
Xc(15,:)= [ 1.0_rk, 0.0_rk, length]
Xc(16,:)= [ 1.0_rk, sqrt(3.0_rk), length]
Xc(17,:)= [-0.5_rk, sqrt(3.0_rk)/2.0_rk, length]
Xc(18,:)= [-2.0_rk, 0.0_rk, length]
Xc(19,:)= [-0.5_rk, -sqrt(3.0_rk)/2.0_rk, length]
Xc(20,:)= [ 1.0_rk, -sqrt(3.0_rk), length]
Xc(21,:)= [ 1.0_rk, 0.0_rk, length]

Xc(15:21,1:2) = Xc(15:21,1:2) * radius1

Xc(22,:)= [ 1.0_rk, 0.0_rk, length]
Xc(23,:)= [ 1.0_rk, sqrt(3.0_rk), length]
Xc(24,:)= [-0.5_rk, sqrt(3.0_rk)/2.0_rk, length]
Xc(25,:)= [-2.0_rk, 0.0_rk, length]
Xc(26,:)= [-0.5_rk, -sqrt(3.0_rk)/2.0_rk, length]
Xc(27,:)= [ 1.0_rk, -sqrt(3.0_rk), length]
Xc(28,:)= [ 1.0_rk, 0.0_rk, length]

Xc(22:28,1:2) = Xc(22:28,1:2) * radius2

! Scale and translate the control points
! Translate the control points
do i = 1, size(Xc, 1)
Xc(i,:) = center + Xc(i,:) * radius1
Xc(i,:) = center + Xc(i,:)
end do

! Define weights for the control points
Expand Down Expand Up @@ -2427,37 +2431,41 @@ pure subroutine set_C(this, center, radius1, radius2, length)

! Define control points for C-shape
allocate(Xc(20, 3))
Xc(1,:)= [ 1.0_rk/2.0_rk, 0.0_rk, 0.0_rk]
Xc(2,:)= [ 1.0_rk/2.0_rk, sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(3,:)= [-0.5_rk/2.0_rk, sqrt(3.0_rk)/4.0_rk, 0.0_rk]
Xc(4,:)= [-2.0_rk/2.0_rk, 0.0_rk, 0.0_rk]
Xc(5,:)= [-0.5_rk/2.0_rk, -sqrt(3.0_rk)/4.0_rk, 0.0_rk]

Xc(6,:)= [ 1.0_rk/2.0_rk, 0.0_rk, 0.0_rk]
Xc(7,:)= [ 1.0_rk/2.0_rk, sqrt(3.0_rk)/2.0_rk, 0.0_rk]
Xc(8,:)= [-0.5_rk/2.0_rk, s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k, length]
Xc(17,:)= [ 1.0_rk/2.0_rk, sqrt(3.0_rk)/2.0_rk, length]
Xc(18,:)= [-0.5_rk/2.0_rk, sqrt(3.0_rk)/4.0_rk, length]
Xc(19,:)= [-2.0_rk/2.0_rk, 0.0_rk, length]
Xc(20,:)= [-0.5_rk/2.0_rk, -sqrt(3.0_rk)/4.0_rk, length]
Xc(11:15,1:2) = Xc(11:15,1:2) * radius1

Xc(16,:)= [ 1.0_rk, 0.0_rk, length]
Xc(17,:)= [ 1.0_rk, sqrt(3.0_rk), length]
Xc(18,:)= [-0.5_rk, sqrt(3.0_rk)/2.0_rk, length]
Xc(19,:)= [-2.0_rk, 0.0_rk, length]
Xc(20,:)= [-0.5_rk, -sqrt(3.0_rk)/2.0_rk, length]

Xc(16:20,1:2) = Xc(16:20,1:2) * radius2

! Scale and translate the control points
! Translate the control points
do i = 1, size(Xc, 1)
Xc(i,:) = center + Xc(i,:) * radius1
Xc(i,:) = center + Xc(i,:)
end do

! Define weights for the control points
Expand Down Expand Up @@ -2495,6 +2503,8 @@ pure subroutine set_half_ring(this, center, radius1, radius2, length)
Xc(4,:) = [-0.5_rk, 0.5_rk, 0.0_rk]
Xc(5,:) = [-0.5_rk, 0.0_rk, 0.0_rk]

Xc(1:5,1:2) = Xc(1:5,1:2) * radius1

Xc(6,:) = [ 0.5_rk, 0.0_rk, 0.0_rk]
Xc(7,:) = [ 0.5_rk, 0.5_rk, 0.0_rk]
Xc(8,:) = [ 0.0_rk, 0.5_rk, 0.0_rk]
Expand All @@ -2509,6 +2519,8 @@ pure subroutine set_half_ring(this, center, radius1, radius2, length)
Xc(14,:) = [-0.5_rk, 0.5_rk, length]
Xc(15,:) = [-0.5_rk, 0.0_rk, length]

Xc(11:15,1:2) = Xc(11:15,1:2) * radius1

Xc(16,:) = [ 0.5_rk, 0.0_rk, length]
Xc(17,:) = [ 0.5_rk, 0.5_rk, length]
Xc(18,:) = [ 0.0_rk, 0.5_rk, length]
Expand All @@ -2517,9 +2529,9 @@ pure subroutine set_half_ring(this, center, radius1, radius2, length)

Xc(16:20,1:2) = Xc(16:20,1:2) * radius2

! Scale and translate the control points
! Translate the control points
do i = 1, size(Xc, 1)
Xc(i,:) = center + Xc(i,:) * radius1
Xc(i,:) = center + Xc(i,:)
end do

! Define weights for the control points
Expand Down

0 comments on commit 4ff6354

Please sign in to comment.