prismatic_ground_slider.Initialize( ground, slider, chrono.ChCoordsysD(chrono.ChVectorD(2, 0, 0), z2x)) system.AddLink(prismatic_ground_slider) ## Distance constraint between crank and slider. ## We provide the points on the two bodies in the global reference frame. ## By default the imposed distance is calculated automatically as the distance ## between these two points in the initial configuration. dist_crank_slider = chrono.ChLinkDistance() dist_crank_slider.SetName("dist_crank_slider") dist_crank_slider.Initialize(crank, slider, False, chrono.ChVectorD(-2, 0, 0), chrono.ChVectorD(2, 0, 0)) system.AddLink(dist_crank_slider) ## 4. Write the system hierarchy to the console (default log output destination) system.ShowHierarchy(chrono.GetLog()) ## 5. Prepare visualization with Irrlicht ## Note that Irrlicht uses left-handed frames with Y up. ## Create the Irrlicht application and set-up the camera. application = chronoirr.ChIrrApp( system, ## pointer to the mechanical system "Slider-Crank Demo 0", ## title of the Irrlicht window chronoirr.dimension2du(800, 600), ## window dimension (width x height) False, ## use full screen? True) ## enable shadows? application.AddTypicalLogo() application.AddTypicalSky() application.AddTypicalLights() application.AddTypicalCamera(
# Created: 1/01/2019 # Copyright: (c) ProjectChrono 2019 #------------------------------------------------------------------------------ print("First tutorial for PyChrono: vectors, matrices etc.") # Load the Chrono::Engine core module! import pychrono as chrono try: import numpy as np from numpy import linalg as LA except ImportError: print("You need NumPyto run this demo!") # Test logging chrono.GetLog().Bar() chrono.GetLog() << "result is: " << 11 + 1.5 << "\n" chrono.GetLog().Bar() # Test vectors my_vect1 = chrono.ChVectorD() my_vect1.x = 5 my_vect1.y = 2 my_vect1.z = 3 my_vect2 = chrono.ChVectorD(3, 4, 5) my_vect4 = my_vect1 * 10 + my_vect2 my_len = my_vect4.Length() print('vect sum =', my_vect1 + my_vect2) print('vect cross =', my_vect1 % my_vect2) print('vect dot =', my_vect1 ^ my_vect2)