Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updateeeee #1

Merged
merged 3 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ dist/
shapenet2kubric/shapenet2kubric.log
examples/KuBasic/Cone/*
Dockerfile
output_tmp/*
4 changes: 2 additions & 2 deletions kubric/core/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def look_at_quat(

# construct the desired coordinate basis front, right, up
look_at_front = normalize(target - position)
look_at_right = normalize(np.cross(world_up, look_at_front), fallback=world_right)
look_at_up = normalize(np.cross(look_at_front, look_at_right))
look_at_right = normalize(np.cross(up, look_at_front), fallback=world_right)
look_at_up = normalize(np.cross(look_at_front, look_at_right), fallback=world_up)

rotation_matrix1 = np.stack([look_at_right, look_at_up, look_at_front])
rotation_matrix2 = np.stack([right, up, front])
Expand Down
12 changes: 7 additions & 5 deletions kubric/randomness.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ def sample_point_in_half_sphere_shell(
"""Uniformly sample points that are in a given distance range from the origin
and with z >= offset."""
while True:
v = rng.uniform((-outer_radius, -outer_radius, offset),
(outer_radius, outer_radius, outer_radius))
len_v = np.linalg.norm(v)
if inner_radius <= len_v <= outer_radius:
return tuple(v)
xyz = rng.normal(0, 1, (3, )) # normalize(3-dim standard normal) is distributed on the unit sphere surface
if xyz[2] < offset: # if z is less than offset, rejection.
continue
xyz = xyz / np.linalg.norm(xyz) # unit vector on the unit sphere surface
radius = rng.uniform(inner_radius**3, outer_radius**3) ** (1/3.) # radius follows surface area of the sphere of radius r
xyz = xyz * radius # projected to the sphere surface of radius r
return tuple(xyz.tolist())
18 changes: 3 additions & 15 deletions kubric/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from absl.flags import argparse_flags

# Copyright 2022 The Kubric Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import collections
import copy
Expand All @@ -50,11 +38,11 @@
# Kubric argparser
# --------------------------------------------------------------------------------------------------

class ArgumentParser(argparse.ArgumentParser):
class ArgumentParser(argparse_flags.ArgumentParser):
"""An argumentparser with default options, and compatibility with the Blender REPL."""

def __init__(self, *args, **kwargs):
argparse.ArgumentParser.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)

# --- default arguments for kubric
self.add_argument("--frame_rate", type=int, default=24,
Expand Down