def generateEccKey(): "Tạo khoá cho hệ mật Elgamal" n = Curve.getCurve()[1] G = Curve.getCurve()[4] k = get_privateKey(n) pk = get_publicKey(k, G) return k, pk
def main(): hexagon = Straight(Point(0, 2), Point(2, 4)).make() + Straight( Point(2, 4), Point(4, 4)).make() + Straight(Point(4, 4), Point( 6, 2)).make() + Straight(Point(6, 2), Point( 4, 0)).make() + Straight(Point(4, 0), Point( 2, 0)).make() + Straight(Point(2, 0), Point(0, 2)).make() print("Hexagon points:\n" + str(hexagon)) draw(hexagon, "hexagon.png") hexagonTranslated = Transformation.translate(hexagon, 1, 2) print("Translated hexagon points:\n" + str(hexagonTranslated)) draw(hexagonTranslated, "hexagonTranslated.png") hexagonRotated = Transformation.rotate(hexagon, 45) print("Rotated hexagon points:\n" + str(hexagonRotated)) draw(hexagonRotated, "hexagonRotated.png") hexagonScalated = Transformation.scale(hexagon, 2) print("Scalated hexagon points:\n" + str(hexagonScalated)) draw(hexagonScalated, "hexagonScalated.png") poligon = [Point(0, 10), Point(40, 30)], [Point(40, 30), Point(20, 50)], [ Point(20, 50), Point(60, 70) ], [Point(60, 70), Point(110, 30) ], [Point(110, 30), Point(130, 0)], [Point(130, 0), Point(100, 30) ], [Point(100, 30), Point(80, 0)], [Point(80, 0), Point(0, 10)] draw( Straight(Point(0, 10), Point(40, 30)).make() + Straight(Point(40, 30), Point(20, 50)).make() + Straight(Point(20, 50), Point(60, 70)).make() + Straight(Point(60, 70), Point(110, 30)).make() + Straight(Point(110, 30), Point(130, 0)).make() + Straight(Point(130, 0), Point(100, 30)).make() + Straight(Point(100, 30), Point(80, 0)).make() + Straight(Point(80, 0), Point(0, 10)).make(), "poligon.png") poligonFill = Fill.scanline(poligon) print(poligonFill) draw(poligonFill, "poligonFill.png") circle = Circle(50).make() print("Circle points:\n" + str(circle)) draw(circle, "circle.png") curve = Curve([Point(0, 0), Point(1, 5), Point(2, 0), Point(3, 3)]).make() print("Curve points:\n" + str(curve)) draw(curve, "curve.png") fill = [] Fill.recursive(Point(2, 3), hexagon, fill) draw(hexagon + fill, "hexagonFill.png")
def __init__(self, oBodyBase, sNameCloth, sClothType, sNameClothSrc): "Separate cloth mesh between skinned and simulated parts, calculating the 'twin verts' that will pin the simulated part to the skinned part at runtime." print( "=== CCloth.ctor() oBodyBase = '{}' sNameCloth = '{}' sClothType = '{}' sNameClothSrc = '{}' ===" .format(oBodyBase.sMeshPrefix, sNameCloth, sClothType, sNameClothSrc)) self.oBodyBase = oBodyBase # The back-reference to the owning bodybase that owns / manages this instance self.sNameCloth = sNameCloth # The human-readable name of this cloth. Is whatever Unity wants to set it. Acts as key in owning CBody.aCloths[] self.sClothType = sClothType # Is one of { 'Shirt', 'Underwear', etc } and determines the cloth collider mesh source. Must match previously-defined meshes created for each body! ###IMPROVE: Define all choices self.sNameClothSrc = sNameClothSrc # The Blender name of the mesh we cut from. (e.g. 'Bodysuit') self.oClothSrc = G.CGlobals.cm_aClothSources[ sNameClothSrc] # Convenience reference to our cloth source. We 'cut' from this at every cloth cutting update self.aMapPinnedParticles = CByteArray( ) # The final flattened map of what verts from the 'skinned cloth vert' map to which verts in the (untouched) Flex-simulated mesh. Flex needs this to create extra springs to keep the skinned part close to where it should be on the body! self.aCurves = [ ] # Array of CCurve objects responsible to cut this cloth as per user directions #--- UV-domain related --- self.oMeshO_UVF = None # Our copy of our ClothSrc's front UV cloth source mesh. We cut this as per user's cutting curves self.oMeshO_UVB = None # Back version of the above self.oMeshO_3DD = None # The resultant cut cloth back into 3D domain. This is what is sent to Unity. self.oMesh_3DD = None # Convenience mesh reference to the above self.oMeshClothSimulated = None # The simulated part of the runtime cloth mesh. Simulated by Flex at runtime. self.oMeshClothSkinned = None # The skinned part of the runtime cloth mesh. Skinned at runtime just like its owning skinned body. (Also responsible to pins simulated mesh) #--- Unity-public properties === self.oObj = CObject.CObject("Cloth Global Parameters") self.oPropNeckStrapThickness = self.oObj.PropAdd( "NeckStrapThickness", "", 0.01, 0.001, 0.1) ###TODO17: #=== Create a empty node in game folder where every mesh related to this body will go === self.oNodeRoot = CreateEmptyBlenderNode( self.oBodyBase.sMeshPrefix + "-Cloth-" + self.sNameCloth, self.oBodyBase.oNodeRoot.name) #===== Add references to the cutting curves that can cut this cloth ===== ###IMPROVE: More complex cloths will have more complexity here to select which curves... self.aCurves.append(Curve.CCurveNeck(self, "Neck")) ###TEMP18: self.aCurves.append(Curve.CCurveSide(self, "Side")) self.aCurves.append(Curve.CCurveTorsoSplit(self, "TorsoSplit"))
def __init__(self, canvasobj, pt0, pt1): #.create_oval(10, 10, 80, 80, outline="#f11", # fill="#1f1", width=2) self.uipts = [pt0, pt1] self.dataline = curv.Line(pt0.datapt, pt1.datapt) self.canvasobj = canvasobj self.view = self.canvasobj.viewer self.style = self.dataline.style #create a second line that is a screen projected version self.scrnline = self.dataline.in_coordsys( targetcoord=self.view.vieweroff) self.visible = True self.canvasline = None
def __init__(self, directory, color): # initialize curves array self.curves = [] # set directoryName to directory parameter and set color self.directoryPath = directory filename = str(directory) filepathString = filename.split("/") end = filepathString[len(filepathString) - 1] # name = end.split(".") self.directoryName = end self.color = color # search the directory folder for all .tsv files files = glob.glob(directory + '/*.tsv') # cycle through all .tsv files for fileName in files: # open each file, read all lines of the file and store to string file = open(fileName, "r") fullFileString = file.readlines() file.close() data = fullFileString # directory = [] x = [] y = [] # index = 0 for index, line in enumerate(data): # split each element in line by delimited character (\t) values = line.split('\t') # store the first value as the offset (#TODO not currently used) if index == 5: baseXOffset = 0 - float(values[2]) baseYOffset = 0 - float(values[4]) # skip the first 27 rows of header information, and store # remaining rows to x and y arrays elif index > 27: if values[3] != '': x.append(float(values[2])) y.append(float(values[3])) # index = index + 1 # Create a curve object and set it's x and y attributes to x and # y arrays curve = Curve.Curve() curve.x = x curve.y = y # find the name of the curve file and set the Curve runID attribute # to the name of the file filepathString = fileName.split("\\") end = filepathString[len(filepathString) - 1] name = end.split(".") curve.runID = name[0] self.curves.append(curve)
def saveShapes(filePath, module, objects): """ Will store shape data in file """ # objects = self.getRegisteredObjects(module , regAttr) writeData = "" for object in objects: writeLine = object + " " # Get shape shape = Transform.getShape(object) # Get CV number cvNum = Curve.getCurveCVNumber(shape) for x in xrange(cvNum): pos = cmds.xform((object + ".cv[" + x + "]"), q=True, ws=True, t=True) writeLine += pos[0] + " " + pos[1] + " " + pos[2] + " " writeData += writeLine + "\n" FILE = open(filePath, "wb") blueprintData = FILE.write(writeData) FILE.close() print ("Saved shape data to : " + filePath)
TempS = input() while TempS[-1] not in ['N', 'n']: if TempS[-1] in ['8']: straight.straightLeg(100, 90, 1000) TempS = input() if TempS[-1] in ['2']: straight.straightLeg(-100, 90, 1000) TempS = input() if TempS[-1] in ['4']: shrinkage.shrinkageLeg(60, 1000) TempS = input() if TempS[-1] in ['6']: straight.straightLeg(60, 0, 1000) TempS = input() if TempS[-1] in ['7']: Curve.CurveLeg(-300, 8, 1000) TempS = input() if TempS[-1] in ['9']: Curve.CurveLeg(300, 8, 1000) TempS = input() if TempS[-1] in ['1']: Curve.CurveLeg(-300, -8, 1000) TempS = input() if TempS[-1] in ['3']: Curve.CurveLeg(300, -8, 1000) TempS = input() if TempS[-1] in ['5']: Curve.CurveLeg(0, 20, 1000) TempS = input() if TempS[-1] in ['0']: Curve.CurveLeg(0, -20, 1000)
def main(): while True: evbuf = jsdev.read(8) if evbuf: time, value, type, number = struct.unpack('IhBB', evbuf) if type & 0x01: if number == XBOX_BUTTON_A: button_states["A"] = value if (value): #if (Index != 1): #straightLink.straightLeg_Link(100,90,1000) #if (Index == 1): straight.straightLeg(120, 90, 500) #Index = 1 elif number == XBOX_BUTTON_B: button_states["B"] = value if (value): #if (Index != 2): #straightLink.straightLeg_Link(60,0,1000) #if (Index == 2): straight.straightLeg(60, 0, 1000) #Index = 2 elif number == XBOX_BUTTON_X: button_states["X"] = value if (value): #if (Index != 3): #straightLink.straightLeg_Link(-100,90,1000) #if (Index == 3): straight.straightLeg(-120, 90, 1000) #Index = 3 elif number == XBOX_BUTTON_Y: button_states["Y"] = value if (value): #if (Index != 4): #straightLink.straightLeg_Link(60,180,1000) #if (Index == 4): straight.straightLeg(60, 180, 1000) #Index = 4 elif number == XBOX_BUTTON_LB: button_states["LB"] = value if (value): #if (Index != 4): #straightLink.straightLeg_Link(60,180,1000) #if (Index == 4): straight.straightLeg(120, 120, 1000) elif number == XBOX_BUTTON_RB: button_states["RB"] = value if (value): #if (Index != 4): #straightLink.straightLeg_Link(60,180,1000) #if (Index == 4): straight.straightLeg(120, 60, 1000) elif number == XBOX_BUTTON_START: button_states["START"] = value elif number == XBOX_BUTTON_BACK: button_states["BACK"] = value elif number == XBOX_BUTTON_HOME: button_states["HOME"] = value elif number == XBOX_BUTTON_LO: button_states["LO"] = value if (value): #if (Index != 4): #straightLink.straightLeg_Link(60,180,1000) #if (Index == 4): straight.straightLeg(60, 240, 1000) elif number == XBOX_BUTTON_RO: button_states["RO"] = value if (value): #if (Index != 4): #straightLink.straightLeg_Link(60,180,1000) #if (Index == 4): straight.straightLeg(60, 270, 1000) #print(button_states) elif type & 0x02: if number == XBOX_AXIS_LX: axis_states["LX"] = value if (value): Curve.CurveLeg(0, 20, 1000) elif number == XBOX_AXIS_LY: axis_states["LY"] = value if (value): Curve.CurveLeg(0, -20, 1000) elif number == XBOX_AXIS_RX: axis_states["RX"] = value elif number == XBOX_AXIS_RY: axis_states["RY"] = value elif number == XBOX_AXIS_LT: axis_states["LT"] = value elif number == XBOX_AXIS_RT: axis_states["RT"] = value elif number == XBOX_AXIS_XX: axis_states["XX"] = value elif number == XBOX_AXIS_YY: axis_states["YY"] = value
from Data import * from ElGammal import * from STS import * center = 7 * "\t" print center + "Opening file ..." path = "./elliptic_curves/Weierstrass/" folder = "cw256/" file = "w256-001.gp" file_path = path + folder + file print center + file_path # print center + "Loading data ..." data = Data(file_path) c = Curve(data.p, data.n, data.a4, data.a6) point = Point(data.gx, data.gy, c, False) print center + "Data Loaded!" print print center + "###########################################" print center + " Diffre-Hellman" print center + "###########################################" raw_input(center + " Start ?") dh_return, error_m = start_DH(point, data.p) print center + error_m # print print center + "###########################################" print center + " El Gammal"
dict_names = { "Eurostoxx 50 Price Index": "STOXX", "Eurostoxx 50 Equal Weight decrement 5% Price Index ( 5% dividend)": "STOXX_DEC" } Nb_Sim = int(sht.range("C13").value) DM = DataManager() Index_Name = dict_names[sht.range( "C11").value] #"STOXX" or "STOXX_DEC" (Stoxx 50 with decrement) discount_curve = Curve(DM) Index = Underlying(Index_Name, DM) Maturity = int(sht.range("C3").value) Barrier = sht.range("C4").value Coupon_Barrier = sht.range("C5").value KI_Barrier = sht.range("C6").value Freq = int(sht.range("C7").value) #in numer of times per year Coupon = sht.range("C9").value Snowball = convert_to_bool(sht.range("C8").value) type_of_vol = sht.range("C12").value def Read_Data(): global Nb_Sim, Index_Name, Index, Maturity, Barrier, Coupon_Barrier, KI_Barrier, Freq, Coupon, Snowball, type_of_vol Nb_Sim = int(sht.range("C13").value)
TempS = input() while TempS[-1] not in ['N', 'n']: if TempS[-1] in ['8']: straight.straightLeg(100, 90, 1000) TempS = input() if TempS[-1] in ['2']: straight.straightLeg(-100, 90, 1000) TempS = input() if TempS[-1] in ['4']: straight.straightLeg(60, 180, 1000) TempS = input() if TempS[-1] in ['6']: straight.straightLeg(60, 0, 1000) TempS = input() if TempS[-1] in ['7']: straight.straightLeg(100, 135, 1000) TempS = input() if TempS[-1] in ['9']: straight.straightLeg(100, 45, 1000) TempS = input() if TempS[-1] in ['1']: straight.straightLeg(-100, 225, 1000) TempS = input() if TempS[-1] in ['3']: straight.straightLeg(-100, 315, 1000) TempS = input() if TempS[-1] in ['5']: Curve.CurveLeg(0, 20, 1000) TempS = input()
def __getCurves(self, run): # Get the curves associated with this run sqlcmd = "select t.IM_Type_ID, t.IM_Type_Measure, t.IM_Type_Value, t.Units, t.IM_Type_Component from Hazard_Curves c, IM_Types t where c.IM_Type_ID = t.IM_Type_ID and c.Run_ID=%d order by t.IM_Type_Value asc" % ( run.getRunID()) if (self.database.execsql(sqlcmd) != 0): self._printError("Unable to retrieve hazard curves.") return None else: curve_data = self.database.getResultsAll() if ((curve_data == None) or (len(curve_data) == 0)): #self._printError("Matching runs not found in DB.") return None else: curves = [] for c in curve_data: # Populate curve object newcurve = Curve() newcurve.setIMID(c[0]) newcurve.setIMMeasure(c[1]) newcurve.setIMValue(c[2]) newcurve.setIMUnits(c[3]) newcurve.setIMComponent(c[4]) curves.append(newcurve) return curves
def test_keypair(): c = Curve('secp256r1') assert c
##梯度下降 import Curve #目标函数 def f(x): return x*x -2*x +1 #f(x)的梯度 def g(x): return 2*x-2 #梯度下降公式 ''' x_start 下降起点 step 步长 g 梯度 ''' def gd(x_start,step,g): x = x_start for i in range(20): grad = g(x) x -= grad*step print('[Epoch{0}] grad={1},x={2}'.format(i,grad,x) ) if abs(grad) < 1e-6: break; return x; gd(5,0.1,g) Curve.curve(f)
def bring_robot(): rospy.init_node("param_demo") rate = rospy.Rate(1) counts = 1 while (not rospy.is_shutdown()): #get param parameter1 = rospy.get_param("/int_param") #在node下的私有变量 # parameter2 = rospy.get_param("/param2", default=222) #全局变量 # print(type(parameter1)) #参数类型 # print(type(parameter2)) #参数类型 rospy.loginfo('Get param1 = %s', parameter1) # rospy.loginfo('Get param2 = %d', parameter2) if parameter1 == 1: print("前行") straight.straightLeg(100, 90, 1000) if parameter1 == 2: print("抬高") # straight.straightLeg(60,180,1000) straight_h.straightLeg_h(60, 90, 1000) if parameter1 == 3: if counts <= 3: print("旋转") Curve.CurveLeg(0, -20, 1000) counts += 1 else: print("狭缝") shrinkage.shrinkageLeg(-100, 1000) counts + +1 if counts == 8: counts = 1 # if TempS == 2: # print("前") # straight.straightLeg(100,90,1000) # if TempS == -2: # print("后") # straight.straightLeg(-100,90,1000) #delete param 删除 # rospy.delete_param('/param2') # #set param 设置 # rospy.set_param('/param2',2) #批量获取参数 # gain_param = rospy.get_param('gains') # p, i, d = gain_param['P'], gain_param['I'], gain_param['D'] # rospy.loginfo("gains are %s, %s, %s", p, i, d) # #get all param names # params = rospy.get_param_names() # rospy.loginfo('param list: %s', params) #check param 判断是否存在 # ifparam = rospy.has_param('/int_param') # if(ifparam): # rospy.loginfo('/int_param exists') # else: # rospy.loginfo('/int_param does not exist') rate.sleep()