選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

169 行
8.5KB

  1. package basispatroonbroek
  2. import (
  3. "math"
  4. "git.wtrh.nl/wouter/gopatterns/pkg/pattern"
  5. "git.wtrh.nl/wouter/gopatterns/pkg/pattern/path"
  6. "git.wtrh.nl/wouter/gopatterns/pkg/pattern/point"
  7. "git.wtrh.nl/wouter/gopatterns/pkg/vector"
  8. )
  9. type Basispatroonbroek struct {
  10. Heupwijdte float64
  11. Taillewijdte float64
  12. Zithoogte float64
  13. Tussenbeenlengte float64
  14. Pijpbreedte float64
  15. Taillebandbreedte float64
  16. ExtraKniebreedte float64
  17. Eigenaar string
  18. }
  19. func (b *Basispatroonbroek) GenereerPatroon() *pattern.Pattern {
  20. p := pattern.NewPattern()
  21. b.generatePoints(p)
  22. b.generateLines(p)
  23. return p
  24. }
  25. func (b *Basispatroonbroek) generatePoints(p *pattern.Pattern) {
  26. //p0 := point.NewAbsolutePoint(0, 0, 0, "0")
  27. //p.AddPoint(p0)
  28. //p1 := p.RelativePoint(p0).WithYOffset(-(b.Zithoogte + 10 - b.Taillebandbreedte)).MarkWith("1").Done()
  29. //// p.AddPoint(point.NewRelativePointBelow(p.GetPoint(0), b.Zithoogte+1-b.Taillebandbreedte, 1))
  30. //p2 := p.RelativePoint(p1).WithYOffset(-b.Tussenbeenlengte).MarkWith("2").Done()
  31. //// p.AddPoint(point.NewRelativePointBelow(p.GetPoint(1), b.Tussenbeenlengte, 2))
  32. //
  33. //p3 := p.RelativePoint(p2).WithYOffset(p1.Vector().Distance(p2.Vector())/2 + 50).
  34. // MarkWith("3").Done()
  35. //
  36. //// p.AddPoint(point.NewRelativePointAbove(p.GetPoint(2), p.GetPoint(1).Vector().Distance(p.GetPoint(2).Vector())/2+5, 3))
  37. //p4 := p.RelativePoint(p1).WithYOffset(b.Zithoogte / 4).MarkWith("4").Done()
  38. //// p.AddPoint(point.NewRelativePointAbove(p.GetPoint(1), b.Zithoogte/4, 4))
  39. //p5 := p.RelativePoint(p1).WithXOffset(-b.Heupwijdte / 12).MarkWith("5").Done()
  40. //// p.AddPoint(point.NewRelativePointLeft(p.GetPoint(1), b.Heupwijdte/12, 5))
  41. //p6 := p.RelativePoint(p4).WithXOffset(-b.Heupwijdte / 12).MarkWith("6").Done()
  42. //// p.AddPoint(point.NewRelativePointLeft(p.GetPoint(4), b.Heupwijdte/12, 6))
  43. //p7 := p.RelativePoint(p0).WithXOffset(-b.Heupwijdte / 12).MarkWith("7").Done()
  44. //// p.AddPoint(point.NewRelativePointLeft(p.GetPoint(0), b.Heupwijdte/12, 7))
  45. //p.RelativePoint(p6).WithXOffset(b.Heupwijdte/4 + 20).MarkWith("8").Done()
  46. //// p.AddPoint(point.NewRelativePointRight(p.GetPoint(6), b.Heupwijdte/4+2, 8))
  47. //p9 := p.RelativePoint(p5).WithXOffset(-(b.Heupwijdte/16 + 5)).MarkWith("9").Done()
  48. //// p.AddPoint(point.NewRelativePointLeft(p.GetPoint(5), b.Heupwijdte/16+0.5, 9))
  49. //p10 := p.RelativePoint(p7).WithXOffset(10).MarkWith("10").Done()
  50. //// p.AddPoint(point.NewRelativePointRight(p.GetPoint(7), 1, 10))
  51. //p.RelativePoint(p10).WithXOffset(b.Taillewijdte/4 + 25).MarkWith("11").Done()
  52. //// p.AddPoint(point.NewRelativePointRight(p.GetPoint(10), b.Taillewijdte/4+2.5, 11))
  53. //p12 := p.RelativePoint(p2).WithXOffset(b.Pijpbreedte / 2).MarkWith("12").Done()
  54. //// p.AddPoint(point.NewRelativePointRight(p.GetPoint(2), b.Pijpbreedte/2, 12))
  55. //p13 := p.RelativePoint(p2).WithXOffset(-b.Pijpbreedte / 2).MarkWith("13").Done()
  56. //// p.AddPoint(point.NewRelativePointLeft(p.GetPoint(2), b.Pijpbreedte/2, 13))
  57. //p14 := p.RelativePoint(p3).WithXOffset(b.Pijpbreedte/2 + b.ExtraKniebreedte).MarkWith("14").Done()
  58. //// p.AddPoint(point.NewRelativePointRight(p.GetPoint(3), b.Pijpbreedte/2+1.5, 14))
  59. //p15 := p.RelativePoint(p3).WithXOffset(-(b.Pijpbreedte/2 + b.ExtraKniebreedte)).MarkWith("15").Done()
  60. //// p.AddPoint(point.NewRelativePointLeft(p.GetPoint(3), b.Pijpbreedte/2+1.5, 15))
  61. //p1To5Distance := p1.Vector().Distance(p5.Vector())
  62. //p16 := p.RelativePoint(p5).WithXOffset(p1To5Distance / 4).MarkWith("16").Done()
  63. //p17 := p.RelativePoint(p6).WithXOffset(p1To5Distance / 4).MarkWith("17").Done()
  64. //p18 := p.RelativePoint(p7).WithXOffset(p1To5Distance / 4).MarkWith("18").Done()
  65. //p.AddPoint(point.NewBetweenPoint(p16, p18, 0.5, "19"))
  66. //p20 := p.RelativePoint(p18).WithXOffset(20).MarkWith("20").Done()
  67. //distance20to21 := 10.0
  68. //p21 := p.RelativePoint(p20).WithYOffset(distance20to21).MarkWith("21").Done()
  69. //p22 := p.RelativePoint(p9).WithXOffset(-(p5.Vector().Distance(p9.Vector())/2 + 5)).MarkWith("22").Done()
  70. //p.RelativePoint(p22).WithYOffset(-5).MarkWith("23").Done()
  71. //distance20to24 := math.Sqrt(math.Pow(b.Taillewijdte/4+45, 2) - math.Pow(distance20to21, 2))
  72. //p24 := p.RelativePoint(p20).WithXOffset(distance20to24).MarkWith("24").Done()
  73. //p.AddPoint(point.NewBetweenPoint(p21, p24, 0.5, "25"))
  74. //p.RelativePoint(p17).WithXOffset(b.Heupwijdte/4 + 30).MarkWith("26").Done()
  75. //p.RelativePoint(p12).WithXOffset(20).MarkWith("27").Done()
  76. //p.RelativePoint(p13).WithXOffset(-20).MarkWith("28").Done()
  77. //p.RelativePoint(p14).WithXOffset(20).MarkWith("29").Done()
  78. //p.RelativePoint(p15).WithXOffset(-20).MarkWith("30").Done()
  79. }
  80. func (b *Basispatroonbroek) generateLines(p *pattern.Pattern) {
  81. p.AddLine(path.NewPath(p.GetPoints("15", "13", "12", "14")...))
  82. p.AddLine(path.NewPath(p.GetPoints("6", "10", "11")...))
  83. p15 := p.GetPoint("15")
  84. p9 := p.GetPoint("9")
  85. p13 := p.GetPoint("13")
  86. pstart15 := point.NewBetweenPoint(p13, p15, 1.5, "109")
  87. p.AddPoint(pstart15)
  88. p.AddLine(path.NewSpline(pstart15, nil, p15, p9))
  89. hp5 := point.NewRelativePointWithVector(p.GetPoint("5"), vector.Vector{X: 30, Y: 0}.Rotate(3*math.Pi/4), "110")
  90. p.AddLine(path.NewSpline(nil, nil, p.GetPoint("6"), hp5, p9))
  91. p25 := p.GetPoint("25")
  92. p21 := p.GetPoint("21")
  93. p24 := p.GetPoint("24")
  94. p19 := p.GetPoint("19")
  95. hp251 := point.NewRelativePoint(p25).WithYOffset(-25 / 2).Done()
  96. hp252 := point.NewRelativePoint(p25).WithYOffset(25 / 2).Done()
  97. hp253 := point.NewRelativePoint(p25).WithXOffset(120).Done()
  98. p.AddLine(path.NewPath(p19, p21, hp251, hp253, hp252, p24))
  99. hp3 := point.NewBetweenPoint(p.GetPoint("14"), p.GetPoint("8"), 0.5, "17")
  100. hp4 := point.NewRelativePointLeft(hp3, 5, "21")
  101. hp7 := point.NewBetweenPoint(p.GetPoint("8"), p.GetPoint("11"), 0.5, "17")
  102. hp8 := point.NewRelativePointRight(hp7, 20, "22")
  103. hp10 := point.NewBetweenPoint(p.GetPoint("12"), p.GetPoint("14"), 1.3, "112")
  104. p.AddLine(path.NewSpline(hp10, hp8, p.GetPoint("14"), hp4, p.GetPoint("8"), p.GetPoint("11")))
  105. hp16 := point.NewRelativePointWithVector(p.GetPoint("16"), vector.Vector{X: 45, Y: 0}.Rotate(3*math.Pi/4), "110")
  106. hp19 := point.NewBetweenPoint(p21, p19, 1.4, "0")
  107. p23 := p.GetPoint("23")
  108. hp23 := point.NewRelativePointWithVector(p23, vector.Vector{X: 70, Y: 0}.Rotate(-math.Pi/10), "111")
  109. p.AddLine(path.NewSpline(hp19, hp23, p19, hp16, p23))
  110. p30 := p.GetPoint("30")
  111. p28 := p.GetPoint("28")
  112. hp30 := point.NewBetweenPoint(p28, p30, 1.5, "0")
  113. p.AddLine(path.NewSpline(nil, hp30, p23, p30))
  114. p.AddLine(path.NewPath(p30, p28))
  115. p29 := p.GetPoint("29")
  116. p27 := p.GetPoint("27")
  117. p.AddLine(path.NewPath(p29, p27))
  118. hp28 := point.NewRelativePointRight(point.NewBetweenPoint(p28, p27, 0.5, "0"), 10, "0")
  119. p.AddLine(path.NewSpline(nil, nil, p27, hp28, p28))
  120. p26 := p.GetPoint("26")
  121. hp13 := point.NewBetweenPoint(p29, p26, 0.5, "17")
  122. hp14 := point.NewRelativePointLeft(hp13, 5, "21")
  123. hp17 := point.NewBetweenPoint(p26, p24, 0.5, "17")
  124. hp18 := point.NewRelativePointRight(hp17, 20, "22")
  125. hp110 := point.NewBetweenPoint(p27, p29, 1.3, "112")
  126. p.AddLine(path.NewSpline(hp110, hp18, p29, hp14, p26, p24))
  127. // p.AddLine(path.NewStraightLine(p.GetPoint(19), p.GetPoint(21)))
  128. // p.AddLine(path.NewStraightLine(hp251, p.GetPoint(21)))
  129. // p.AddLine(path.NewStraightLine(hp251, hp253))
  130. // p.AddLine(path.NewStraightLine(hp252, hp253))
  131. // p.AddLine(path.NewStraightLine(hp252, p.GetPoint(24)))
  132. // p19 := p.GetPoint(19)
  133. // p23 := p.GetPoint(23)
  134. // p.AddLine(path.NewMultiPointCurve(0.0, p.GetPoint(21).Position().Direction(p.GetPoint(19).Position()), p23, p19))
  135. // p.AddLine(path.NewMultiPointCurve(-0.18, -math.Pi+0.18, p.GetPoints(28, 27)...))
  136. // hp9 := point.NewBetweenPoint(p.GetPoint(29), p.GetPoint(26), 0.5, 0)
  137. // hp10 := point.NewRelativePointLeft(hp9, 0.3, 0)
  138. // p.AddLine(path.NewMultiPointCurve(math.Pi/2, -math.Pi/2, p.GetPoint(29), hp10, p.GetPoint(26), p.GetPoint(24)))
  139. // p.AddLine(path.NewMultiPointCurve(p.GetPoint(28).Position().Direction(p.GetPoint(30).Position()), -math.Pi/2, p.GetPoint(30), p.GetPoint(23)))
  140. // p.AddLine(path.NewStraightLine(p.GetPoint(28), p.GetPoint(30)))
  141. // p.AddLine(path.NewStraightLine(p.GetPoint(27), p.GetPoint(29)))
  142. }
  143. //func (b *Basispatroonbroek) Voorbeen(canvas *svg.SVG) {
  144. // p := b.GeneratePoints().Normalize()
  145. // p.Draw(canvas)
  146. // p.Line(canvas, 15, 13, 12, 14)
  147. // p.Line(canvas, 10, 11)
  148. // pa := p[14].Above(p[14].Distance(p[8]) / 3)
  149. // pb := p[8].Below(p[14].Distance(p[8]) / 3)
  150. // util.Bezier(canvas, p[14], pa, pb, p[8])
  151. // p15p9half := p[9].Subtract(p[15]).Divide(2)
  152. // pc := p[15].Add(p15p9half).Add(p15p9half.Unit().Rotate(math.Pi / 2).Multiply(3 * float64(b.Eenheid)))
  153. //
  154. // util.Qbez(canvas, p[9], pc, p[15])
  155. //}