OSP Display3DFrame and 3D elements work from Python jpype but not AbstractSimulation
ALFONSO REYES
9 Posts
Hello, I am having some difficulties calling OSP Java libraries from Python using jpype. Specifically, I am not able to properly call AbstractSimulation or AbstractCalculation which are the core and butter of java physics simulation.
Could anybody help me?
This simple example, for instance, works for me. But have tried for hours to call AbstractSimulation or AbstractCalculation without success.
Thanks, Alfonso
# Display3DFrameApp import jpype
def init_jvm(jvmpath=None): # indicate the java JAR file jar_path = 'osp.jar' if jpype.isJVMStarted(): return
# get the whole OSP package javaPackage = jpype.JPackage("org").opensourcephysics Display3DFrame = javaPackage.frames.Display3DFrame ElementCircle = javaPackage.display3d.simple3d.ElementCircle
import math import numpy as np frame = Display3DFrame("Random Circles")
for i in range(0,25): ball = ElementCircle() ball.setSizeXYZ(0.1, 0.1, 0.1) ball.setXYZ(-1.0+2*np.random.random(), -1.0+2*np.random.random(), -1.0+2*np.random.random()) frame.addElement(ball)