def execute(self, context): # x=Asin(at+delta ),y=Bsin(bt) if self.waveA == 'sine': xstring = ssine(self.amplitude_A, self.period_A, phase_shift=self.shift) elif self.waveA == 'triangle': xstring = str(triangle(100, self.period_A, self.amplitude_A)) if self.waveB == 'sine': ystring = ssine(self.amplitude_B, self.period_B) elif self.waveB == 'triangle': ystring = str(triangle(100, self.period_B, self.amplitude_B)) print("x= " + str(xstring)) print("y= " + str(ystring)) x = Expression(xstring, ["t"]) # make equation from string y = Expression(ystring, ["t"]) # make equation from string # build function to be passed to create parametric curve () def f(t, offset: float = 0.0): c = (x(t), y(t), 0) return c parametric.create_parametric_curve(f, offset=0.0, min=self.mint, max=self.maxt, use_cubic=True, iterations=self.iteration) return {'FINISHED'}
def execute(self, context): #x=Asin(at+delta ),y=Bsin(bt) xstring = str(round(self.amplitude_A, 6)) + "*sin((2*pi/" + str( round(self.period_A, 6)) + ")*(t+" + str(round(self.shift, 6)) + "))" ystring = str(round(self.amplitude_B, 6)) + "*sin((2*pi/" + str( round(self.period_B, 6)) + ")*(t))" print("x= " + str(xstring)) print("y= " + str(ystring)) x = Expression(xstring, ["t"]) #make equation from string y = Expression(ystring, ["t"]) #make equation from string #build function to be passed to create parametric curve () def f(t, offset: float = 0.0): c = (x(t), y(t), 0) return c parametric.create_parametric_curve(f, offset=0.0, min=self.mint, max=self.maxt, use_cubic=True, iterations=self.iteration) return {'FINISHED'}
def execute(self, context): #z=Asin(B(x+C))+D zstring = str(round(self.offset, 6)) + "+" + str( round(self.amplitude, 6)) + "*sin((2*pi/" + str( round(self.period, 6)) + ")*(t+" + str(round(self.shift, 6)) + "))" print(zstring) e = Expression(zstring, ["t"]) #make equation from string #build function to be passed to create parametric curve () def f(t, offset: float = 0.0): if self.axis == "XY": c = (e(t), t, 0) elif self.axis == "YX": c = (t, e(t), 0) elif self.axis == "ZX": c = (t, 0, e(t)) elif self.axis == "ZY": c = (0, t, e(t)) return c parametric.create_parametric_curve(f, offset=0.0, min=self.mint, max=self.maxt, use_cubic=True, iterations=self.iteration) return {'FINISHED'}
def execute(self, context): # z=Asin(B(x+C))+D if self.wave == 'sine': zstring = ssine(self.amplitude, self.period, dc_offset=self.offset, phase_shift=self.shift) if self.beatperiod != 0: zstring += "+" + ssine(self.amplitude, self.period + self.beatperiod, dc_offset=self.offset, phase_shift=self.shift) elif self.wave == 'triangle': #build triangle wave from fourier series zstring = str(round(self.offset, 6)) + "+(" + str( triangle(80, self.period, self.amplitude)) + ")" if self.beatperiod != 0: zstring += '+' + str( triangle(80, self.period + self.beatperiod, self.amplitude)) elif self.wave == 'cycloid': zstring = "abs(" + ssine(self.amplitude, self.period, dc_offset=self.offset, phase_shift=self.shift) + ")" elif self.wave == 'invcycloid': zstring = "-1*abs(" + ssine(self.amplitude, self.period, dc_offset=self.offset, phase_shift=self.shift) + ")" print(zstring) e = Expression(zstring, ["t"]) # make equation from string # build function to be passed to create parametric curve () def f(t, offset: float = 0.0, angle_offset: float = 0.0): if self.axis == "XY": c = (e(t + angle_offset) + offset, t, 0) elif self.axis == "YX": c = (t, e(t + angle_offset) + offset, 0) elif self.axis == "ZX": c = (t, offset, e(t + angle_offset)) elif self.axis == "ZY": c = (offset, t, e(t + angle_offset)) return c for i in range(self.wave_amount): angle_off = self.wave_angle_offset * self.period * i / (2 * math.pi) parametric.create_parametric_curve(f, offset=self.wave_distance * i, min=self.mint, max=self.maxt, use_cubic=True, iterations=self.iteration, angle_offset=angle_off) return {'FINISHED'}
def execute(self, context): r = round(self.r, 6) R = round(self.R, 6) d = round(self.d, 6) Rmr = round(R - r, 6) # R-r Rpr = round(R + r, 6) # R +r Rpror = round(Rpr / r, 6) # (R+r)/r Rmror = round(Rmr / r, 6) # (R-r)/r maxangle = 2 * math.pi * ( (np.lcm(round(self.R * 1000), round(self.r * 1000)) / (R * 1000))) if self.typecurve == "hypo": xstring = str(Rmr) + "*cos(t)+" + str(d) + "*cos(" + str( Rmror) + "*t)" ystring = str(Rmr) + "*sin(t)-" + str(d) + "*sin(" + str( Rmror) + "*t)" else: xstring = str(Rpr) + "*cos(t)-" + str(d) + "*cos(" + str( Rpror) + "*t)" ystring = str(Rpr) + "*sin(t)-" + str(d) + "*sin(" + str( Rpror) + "*t)" zstring = '(' + str(round( self.dip, 6)) + '*(sqrt(((' + xstring + ')**2)+((' + ystring + ')**2))))' print("x= " + str(xstring)) print("y= " + str(ystring)) print("z= " + str(zstring)) print("maxangle " + str(maxangle)) x = Expression(xstring, ["t"]) # make equation from string y = Expression(ystring, ["t"]) # make equation from string z = Expression(zstring, ["t"]) # make equation from string # build function to be passed to create parametric curve () def f(t, offset: float = 0.0): c = (x(t), y(t), z(t)) return c iter = int(maxangle * 10) if iter > 10000: # do not calculate more than 10000 points print("limiting calculatons to 10000 points") iter = 10000 parametric.create_parametric_curve(f, offset=0.0, min=0, max=maxangle, use_cubic=True, iterations=iter) return {'FINISHED'}
def execute(self, context): print("x= " + self.xstring) print("y= " + self.ystring) print("z= " + self.zstring) ex = Expression(self.xstring, ["t"]) # make equation from string ey = Expression(self.ystring, ["t"]) # make equation from string ez = Expression(self.zstring, ["t"]) # make equation from string # build function to be passed to create parametric curve () def f(t, offset: float = 0.0): c = (ex(t), ey(t), ez(t)) return c parametric.create_parametric_curve(f, offset=0.0, min=self.mint, max=self.maxt, use_cubic=True, iterations=self.iteration) return {'FINISHED'}